Help is appreciated, code is below.
Thanks,
-Sam
Here's the code that defines my form:
from turbogears.widgets import WidgetsList, HiddenField, FileField, Form
from turbogears.validators import NotEmpty, Schema
class CattailForm(Form):
template = '''<<Kid template omitted>>'''
params = []
params_doc = {}
class UploadFields(WidgetsList):
mail = HiddenField()
upload_file = FileField(validator=NotEmpty)
upload_file.label = ''
UPLOAD_FORM = CattailForm(fields=UploadFields(), submit_text="Upload")
Here's the code before the function that the form calls:
@expose()
@validate(form=UPLOAD_FORM) #error at this line
@error_handler(user)
Here's the code in my error handler function (function for the page that includes the form originally) that's supposed to display the error messages (code obtained from an earlier thread on the list ( http://www.mail-archive.com/[email protected]/msg15148.html)):
if tg_errors:
cherrypy.request.validated_form = UPLOAD_FORM
Finally, here's the stack trace:
Page handler: <bound method Root.upload of <cattail.controllers.Root object at 0xb79928ec>>
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/CherryPy-2.2.1-py2.4.egg/cherrypy/_cphttptools.py", line 105, in _run
self.main()
File "/usr/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 upload
File "/opt/turbogears/turbogears/identity/conditions.py", line 235, in require
return fn(self, *args, **kwargs)
File "<string>", line 3, in upload
File "/opt/turbogears/turbogears/controllers.py", line 281, in expose
output = database.run_with_transaction(
File "<string>", line 5, in run_with_transaction
File "/opt/turbogears/turbogears/database.py", line 245, in so_rwt
retval = func(*args, **kw)
File "<string>", line 5, in _expose
File "/opt/turbogears/turbogears/controllers.py", line 298, in <lambda>
mapping, fragment, *args, **kw)))
File "/opt/turbogears/turbogears/controllers.py", line 322, in _execute_func
output = errorhandling.try_call(func, *args, **kw)
File "/opt/turbogears/turbogears/errorhandling.py", line 68, in try_call
return func(self, *args, **kw)
File "<string>", line 3, in upload
File "/opt/turbogears/turbogears/controllers.py", line 127, in validate
kw.update(form.validate(value, state))
File "/opt/turbogears/turbogears/widgets/forms.py", line 1046, in validate
return self.validator.to_python(value, state)
File "/usr/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 "/usr/lib/python2.4/site-packages/FormEncode- 0.5.1-py2.4.egg/formencode/schema.py", line 132, in _to_python
new[name] = validator.to_python(value, state)
File "/usr/lib/python2.4/site-packages/FormEncode-0.5.1-py2.4.egg/formencode/api.py", line 319, in to_python
vp(value, state)
File "/usr/lib/python2.4/site-packages/FormEncode-0.5.1-py2.4.egg/formencode/validators.py", line 420, in validate_python
if not value:
File "/usr/lib/python2.4/cgi.py", line 625, in __len__
return len(self.keys())
File "/usr/lib/python2.4/cgi.py", line 601, in keys
raise TypeError, "not indexable"
TypeError: not indexable
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

