Re: [FE-discuss] formencode invalid exception

Top Page
Author: Anil
Date:  
To: Ian Bicking
CC: pylons-discuss, Allan Saddi, formencode-discuss
Subject: Re: [FE-discuss] formencode invalid exception
I have:
    def reset(self):
        """ Reset password for email given in POST arguments """
        from formencode import validators

        mail_validator = validators.Email(not_empty=True)
        try:
            mail = request.params.get("mail")
            mail_validator.to_python(mail)
        except validators.Invalid, e:
            return e

Which is called through a AJAX h.submit_to_remote call, which updates
a DIV element with the "e".


Actually, I sent an email to Allan before, and he sent:

The application/framework is responsible for all encoding/decoding,
according to the WSGI spec:

http://www.python.org/dev/peps/pep-0333/#unicode-issues

The WSGI interface only supports plain strings.

- Allan



On Nov 29, 2007 11:56 AM, Ian Bicking <ianb@???> wrote:
> 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 : ianb@??? : 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
_______________________________________________
FormEncode-discuss mailing list
FormEncode-discuss@???
https://lists.sourceforge.net/lists/listinfo/formencode-discuss