Steven James wrote:
> I tried like this:
>
> @turbogears.expose()
> @turbogears.validate(validators=setEmailForwardSchema)
> def setEmailForward(self, ...
>
> I get this traceback:
>
> Page handler: <bound method Root.setEmailForward of
> <ctiwebmin.controllers.Root object at 0x01040A10>>
> Traceback (most recent call last):
> File
> "c:\python24\lib\site-packages\CherryPy-2.2.0betadev_r980-py2.4.egg\cherrypy\_cphttptools.py",
> line 99, in _run
> self.main()
> File
> "c:\python24\lib\site-packages\CherryPy-2.2.0betadev_r980-py2.4.egg\cherrypy\_cphttptools.py",
> line 248, in main
> body = page_handler(*virtual_path, **self.params)
> File "<string>", line 3, in setEmailForward
> File
> "c:\python24\lib\site-packages\TurboGears-0.9a1-py2.4.egg\turbogears\controllers.py",
> line 210, in expose
> tg_format, html, fragment, *args, **kw)
> File
> "c:\python24\lib\site-packages\TurboGears-0.9a1-py2.4.egg\turbogears\database.py",
> line 193, in run_with_transaction
> retval = func(*args, **kw)
> File
> "c:\python24\lib\site-packages\TurboGears-0.9a1-py2.4.egg\turbogears\controllers.py",
> line 228, in _execute_func
> output = errorhandling.try_call(func, *args, **kw)
> File
> "c:\python24\lib\site-packages\TurboGears-0.9a1-py2.4.egg\turbogears\errorhandling.py",
> line 63, in try_call
> output = func(self, *args, **kw)
> File "<string>", line 3, in setEmailForward
> File
> "c:\python24\lib\site-packages\TurboGears-0.9a1-py2.4.egg\turbogears\controllers.py",
> line 136, in validate
> errors.update(error.unpack_errors())
> ValueError: dictionary update sequence element #0 has length 1; 2 is
> required
You seem to have stumbled on to a bug. r842 fixes this, or if don't like
using a SVN version, you will find attached just the relevant patch. Thanks!
Cheers,
Simon
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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
-~----------~----~----~----~------~----~------~--~---
Index: trunk/turbogears/controllers.py
===================================================================
--- trunk/turbogears/controllers.py (revision 823)
+++ trunk/turbogears/controllers.py (revision 842)
@@ -20,5 +20,4 @@
unicodechars = re.compile(r"([^\x00-\x7F])")
-
def _process_output(tg_format, output, template, fragment=False):
@@ -134,10 +133,13 @@
except tg_validators.Invalid, error:
if hasattr(error, "unpack_errors"):
- errors.update(error.unpack_errors())
- elif getattr(error, "error_dict", {}):
- errors.update(error.error_dict)
+ error = error.unpack_errors()
+ elif hasattr(error, "error_dict"):
+ error = error.error_dict
+ if isinstance(error, dict):
+ errors.update(error)
else:
errors = error
- kw = errorhandling.dispatch_failsafe(failsafe_schema,
+ if errors:
+ kw = errorhandling.dispatch_failsafe(failsafe_schema,
failsafe_values, errors, func, kw)
if form: