Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #955 (closed enhancement: fixed)

Opened 13 years ago

Last modified 12 years ago

Nice warning or better exception requested.

Reported by: S Brown <trac.turbogears@…> Owned by: anonymous
Priority: normal Milestone: 1.0b2
Component: TurboGears Version: 0.9a6
Severity: normal Keywords:


I get the following error:

File "/usr/lib/python2.4/site-packages/TurboGears-0.9a6-py2.4.egg/turbogears/validators.py", line 58, in _to_python

value = format.parse_decimal(value)

File "/usr/lib/python2.4/site-packages/TurboGears-0.9a6-py2.4.egg/turbogears/i18n/format.py", line 165, in parse_decimal

value = value.replace(get_group_format(locale), "")

AttributeError?: 'int' object has no attribute 'replace'

This happens because: I was expecting the user to input a variable like start=123 in a web form. But in my controller code I check to see if it's empty and if so, I add the key to the kwargs and a default value.

The problem was when I added the default value like so:

kwargs['start'] = 123

When I should have done this:

kwargs['start'] = "123"

ie, I should have used a string. It would be nice if Turbogears had a warning about this when the value went through the validator, or if the Exception was thrown earlier, or was more descriptive (or both)

Change History

comment:1 Changed 13 years ago by jorge.vargas

  • Milestone set to 1.0b2

your asking for type checkign?

cherrypy works based on strings. same as the rest of the web.

I honestly don't undestand what's happening here that's tg fault.

shall we implement this?

comment:2 Changed 13 years ago by alberto

  • Status changed from new to closed
  • Resolution set to fixed

I've fixed this based on the way FE validators seem to work. For example:

>>> Int.to_python("2")
>>> Int.to_python(2)

Comitted fix + test at [2254]


Note: See TracTickets for help on using tickets.