John Dickson
2009-03-10 11:32:15 UTC
Hi folks
I've recently run into lots of problems with validation in an app of mine,
after upgrading to formencode 1.2.x. This is a Pylons-based app (I've also
just upgraded Pylons from 0.9.6 to 0.9.7), which has been working fine for a
number of people until these upgrades. I've been beating my head against a
brick wall trying to diagnose this for a couple of days now, and still
haven't got anywhere, so I'd be *really* grateful for any pointers you could
give.
I have to say, though, that I'm pretty much a newbie on formencode. I'm
also also only guessing that this is a formencode issue, but it may well be
Pylons.
My controllers use the Pylons @validate decorator. Everything is fine if
there are no errors detected by the decorator (using a subclass of Schema),
but if any validation failure occurs I get a KeyError when trying to run the
controller method to redisplay the form. Examining the request, I see that
params, GET and POST are all empty (UnicodeMultiDict objects), while the
WSGI webob._parsed_post_vars variable seems to have all my POST fields in it
(exactly what I'd have expected to see in params).
I'm including a stack trace below, in case that's of any assistance. Thanks
in advance for your help.
Cheers .................................... John Dickson
Traceback (most recent call last):
File "/home/johnd/python/jcr-0.6.7/jcr/lib/base.py", line 98, in __call__
return WSGIController.__call__(self, environ, start_response)
File
"/usr/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/core.py",
line 221, in __call__
response = self._dispatch_call()
File
"/usr/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/core.py",
line 172, in _dispatch_call
response = self._inspect_call(func)
File
"/usr/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/core.py",
line 107, in _inspect_call
result = self._perform_call(func, args)
File
"/usr/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/core.py",
line 60, in _perform_call
return func(**args)
File "<string>", line 2, in upload
File
"/usr/lib/python2.5/site-packages/AuthKit-0.4.3-py2.5.egg/authkit/authorize/pylons_adaptors.py",
line 36, in validate
return permission.check(app, request.environ, self.start_response)
File
"/usr/lib/python2.5/site-packages/AuthKit-0.4.3-py2.5.egg/authkit/permissions.py",
line 177, in check
return app(environ, start_response)
File
"/usr/lib/python2.5/site-packages/AuthKit-0.4.3-py2.5.egg/authkit/authorize/pylons_adaptors.py",
line 35, in app
return func(self, *args, **kwargs)
File "<string>", line 2, in upload
File
"/usr/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/decorators/__init__.py",
line 161, in wrapper
response = self._dispatch_call()
File
"/usr/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/core.py",
line 172, in _dispatch_call
response = self._inspect_call(func)
File
"/usr/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/core.py",
line 107, in _inspect_call
result = self._perform_call(func, args)
File
"/usr/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/core.py",
line 60, in _perform_call
return func(**args)
File "<string>", line 2, in index
File
"/usr/lib/python2.5/site-packages/AuthKit-0.4.3-py2.5.egg/authkit/authorize/pylons_adaptors.py",
line 36, in validate
return permission.check(app, request.environ, self.start_response)
File
"/usr/lib/python2.5/site-packages/AuthKit-0.4.3-py2.5.egg/authkit/permissions.py",
line 177, in check
return app(environ, start_response)
File
"/usr/lib/python2.5/site-packages/AuthKit-0.4.3-py2.5.egg/authkit/authorize/pylons_adaptors.py",
line 35, in app
return func(self, *args, **kwargs)
File
"/home/johnd/python/jcr-0.6.7/jcr/controllers/projectadmin/selectfileset.py",
line 52, in index
c.projectId = int(request.params['projectId'])
File "build/bdist.linux-i686/egg/webob/multidict.py", line 314, in
__getitem__
return self._decode_value(self.multi.__getitem__(self._encode_key(key)))
File "build/bdist.linux-i686/egg/webob/multidict.py", line 440, in
__getitem__
raise KeyError(key)
KeyError: 'projectId'
I've recently run into lots of problems with validation in an app of mine,
after upgrading to formencode 1.2.x. This is a Pylons-based app (I've also
just upgraded Pylons from 0.9.6 to 0.9.7), which has been working fine for a
number of people until these upgrades. I've been beating my head against a
brick wall trying to diagnose this for a couple of days now, and still
haven't got anywhere, so I'd be *really* grateful for any pointers you could
give.
I have to say, though, that I'm pretty much a newbie on formencode. I'm
also also only guessing that this is a formencode issue, but it may well be
Pylons.
My controllers use the Pylons @validate decorator. Everything is fine if
there are no errors detected by the decorator (using a subclass of Schema),
but if any validation failure occurs I get a KeyError when trying to run the
controller method to redisplay the form. Examining the request, I see that
params, GET and POST are all empty (UnicodeMultiDict objects), while the
WSGI webob._parsed_post_vars variable seems to have all my POST fields in it
(exactly what I'd have expected to see in params).
I'm including a stack trace below, in case that's of any assistance. Thanks
in advance for your help.
Cheers .................................... John Dickson
Traceback (most recent call last):
File "/home/johnd/python/jcr-0.6.7/jcr/lib/base.py", line 98, in __call__
return WSGIController.__call__(self, environ, start_response)
File
"/usr/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/core.py",
line 221, in __call__
response = self._dispatch_call()
File
"/usr/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/core.py",
line 172, in _dispatch_call
response = self._inspect_call(func)
File
"/usr/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/core.py",
line 107, in _inspect_call
result = self._perform_call(func, args)
File
"/usr/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/core.py",
line 60, in _perform_call
return func(**args)
File "<string>", line 2, in upload
File
"/usr/lib/python2.5/site-packages/AuthKit-0.4.3-py2.5.egg/authkit/authorize/pylons_adaptors.py",
line 36, in validate
return permission.check(app, request.environ, self.start_response)
File
"/usr/lib/python2.5/site-packages/AuthKit-0.4.3-py2.5.egg/authkit/permissions.py",
line 177, in check
return app(environ, start_response)
File
"/usr/lib/python2.5/site-packages/AuthKit-0.4.3-py2.5.egg/authkit/authorize/pylons_adaptors.py",
line 35, in app
return func(self, *args, **kwargs)
File "<string>", line 2, in upload
File
"/usr/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/decorators/__init__.py",
line 161, in wrapper
response = self._dispatch_call()
File
"/usr/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/core.py",
line 172, in _dispatch_call
response = self._inspect_call(func)
File
"/usr/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/core.py",
line 107, in _inspect_call
result = self._perform_call(func, args)
File
"/usr/lib/python2.5/site-packages/Pylons-0.9.7-py2.5.egg/pylons/controllers/core.py",
line 60, in _perform_call
return func(**args)
File "<string>", line 2, in index
File
"/usr/lib/python2.5/site-packages/AuthKit-0.4.3-py2.5.egg/authkit/authorize/pylons_adaptors.py",
line 36, in validate
return permission.check(app, request.environ, self.start_response)
File
"/usr/lib/python2.5/site-packages/AuthKit-0.4.3-py2.5.egg/authkit/permissions.py",
line 177, in check
return app(environ, start_response)
File
"/usr/lib/python2.5/site-packages/AuthKit-0.4.3-py2.5.egg/authkit/authorize/pylons_adaptors.py",
line 35, in app
return func(self, *args, **kwargs)
File
"/home/johnd/python/jcr-0.6.7/jcr/controllers/projectadmin/selectfileset.py",
line 52, in index
c.projectId = int(request.params['projectId'])
File "build/bdist.linux-i686/egg/webob/multidict.py", line 314, in
__getitem__
return self._decode_value(self.multi.__getitem__(self._encode_key(key)))
File "build/bdist.linux-i686/egg/webob/multidict.py", line 440, in
__getitem__
raise KeyError(key)
KeyError: 'projectId'