Re: formencode invalid exception

Ian Bicking <[email protected]>
Newsgroups gmane.comp.python.formencode,gmane.comp.web.pylons.general
Message-ID <[email protected]>
Anil wrote:
> I am using Formencode and it seems that it throws an uuencoded Invalid
> exception and flup seems to have problems with it. I don't notice it
> on another server with the same code and same version of Pylons/flup.
> 
> Whats the best way to fix this? If I should encode the form "error
> message" to utf-8, where and how should I do that?

This is probably a flup bug, as it should handle unicode exceptions 
properly.

Of course generally you catch Invalid exceptions and handle them.  But 
flup should handle it more gracefully when you don't.

I've copied Allan, the flup author, on this.

> 
> <type 'exceptions.AssertionError'>	Python 2.5.1: /usr/local/bin/python2.5
> Thu Nov 29 11:32:34 2007
> 
> A problem occurred in a Python script. Here is the sequence of
> function calls leading up to the error, in the order they occurred.
>  /opt/abc/build/bdist.freebsd-6.2-RELEASE-amd64/egg/flup/server/scgi_base.py
> in run(self=<flup.server.scgi_base.Request object at 0x8d9f82c>)
>   183
>   184         try:
>   185             self._conn.server.handler(self)
>   186         except:
>   187             self.logger.exception('Exception caught from handler')
>  /opt/abc/build/bdist.freebsd-6.2-RELEASE-amd64/egg/flup/server/scgi_base.py
> in handler(self=<flup.server.scgi.WSGIServer object at 0x849e8ec>,
> request=<flup.server.scgi_base.Request object at 0x8d9f82c>)
>   458                     for data in result:
>   459                         if data:
>   460                             write(data)
>   461                     if not headers_sent:
>   462                         write('') # in case body was empty
>  /opt/abc/build/bdist.freebsd-6.2-RELEASE-amd64/egg/flup/server/scgi_base.py
> in write(data=Invalid(u'Please enter an email address',))
>   400
>   401         def write(data):
>   402             assert type(data) is str, 'write() argument must be string'
>   403             assert headers_set, 'write() before start_response()'
>   404
> 
> <type 'exceptions.AssertionError'>: write() argument must be string

-- 
Ian Bicking : [email protected] : http://blog.ianbicking.org

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.