Re: KeyError on validation failure after upgrading formencode
Ian Bicking <[email protected]> Thu, 12 Mar 2009 13:42:46 -0500
| Newsgroups | gmane.comp.python.formencode |
|---|---|
| Message-ID | <[email protected]> |
I'm wonder if perhaps this is an AuthKit/WebOb conflict. It might be that AuthKit is reading in the parameters of POST requests in such a way that WebOb can't see them. You could test by creating a POST form with a simple controller, and seeing if the POST variables get swallowed. It isn't necessarily AuthKit that is swallowing them, but it seems like a good chance (disabling AuthKit and testing would make it clear). On Tue, Mar 10, 2009 at 6:32 AM, John Dickson <[email protected]> wrote: > 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' > > > ------------------------------------------------------------------------------ > > _______________________________________________ > FormEncode-discuss mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/formencode-discuss > > -- Ian Bicking | http://blog.ianbicking.org ------------------------------------------------------------------------------ Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are powering Web 2.0 with engaging, cross-platform capabilities. Quickly and easily build your RIAs with Flex Builder, the Eclipse(TM)based development software that enables intelligent coding and step-through debugging. Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com _______________________________________________ FormEncode-discuss mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/formencode-discuss