#824: Number validator not working
------------------------+---------------------------------------------------
Reporter: anonymous | Owner: anonymous
Type: defect | Status: new
Priority: normal | Milestone:
Component: TurboGears | Version: 0.9a5
Severity: normal | Keywords:
------------------------+---------------------------------------------------
After upgrading from 0.9a4 to 0.9a5 I encountered the following problem
with my project:
Background: In a controller file I have a validator set up as: validators
= { "last_sync_date": validators.Number() } and the number supplied was:
1146671186.081156.
When running I got the following error:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4
/site-packages/CherryPy-2.2.1-py2.4.egg/cherrypy/_cphttptools.py", line
105, in _run
self.main()
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4
/site-packages/CherryPy-2.2.1-py2.4.egg/cherrypy/_cphttptools.py", line
254, in main
body = page_handler(*virtual_path, **self.params)
File "<string>", line 3, in newFunction
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4
/site-packages/TurboGears-0.9a5-py2.4.egg/turbogears/controllers.py", line
210, in expose
output = database.run_with_transaction(func._expose,func, accept,
allow_json, allow_json_from_config,*args, **kw)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4
/site-packages/TurboGears-0.9a5-py2.4.egg/turbogears/database.py", line
216, in run_with_transaction
retval = func(*args, **kw)
File "<string>", line 5, in _expose
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4
/site-packages/TurboGears-0.9a5-py2.4.egg/turbogears/controllers.py", line
230, in <lambda>
func._expose.when(rule)(lambda _func, accept, allow_json,
allow_json_from_config,*args,**kw: _execute_func(
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4
/site-packages/TurboGears-0.9a5-py2.4.egg/turbogears/controllers.py", line
251, in _execute_func
output = errorhandling.try_call(func, *args, **kw)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4
/site-packages/TurboGears-0.9a5-py2.4.egg/turbogears/errorhandling.py",
line 71, in try_call
return func(self, *args, **kw)
File "/Volumes/Litter
Box/Users/stodd/Documents/Contracts/[EMAIL
PROTECTED]/Projects/contact/contact/controllers/group.py",
line 22, in newFunction
theItems = [(theKey,
validators[theKey].to_python(theDictionary[theKey])) for theKey in
theValidationKeys]
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4
/site-packages/FormEncode-0.5.1-py2.4.egg/formencode/api.py", line 316, in
to_python
value = tp(value, state)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4
/site-packages/TurboGears-0.9a5-py2.4.egg/turbogears/validators.py", line
57, in _to_python
value = format.parse_decimal(value)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4
/site-packages/TurboGears-0.9a5-py2.4.egg/turbogears/i18n/format.py", line
165, in parse_decimal
value = value.replace(get_group_format(locale), "")
AttributeError: 'float' object has no attribute 'replace'
Is this a bug that was introduced in 0.9a5?
If I comment out this validator, everything works as expected.
--
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/824>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Tickets" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets
-~----------~----~----~----~------~----~------~--~---