Hi James,

On Apr 2, 5:49 pm, James Gardner <[EMAIL PROTECTED]> wrote:
> Hi Frederik,
>
> Is this now resolved with Ian's new FormEncode release? If not, can you
> send me some code that breaks and I'll look into it.

No, it's still broken. The code is simply from the pylons guide for
FormBuild: http://formbuild.org/docs/pylons.html

All works fine with pylons built-in form validation as described in
http://pylonshq.com/docs/0.9.4.1/form_handling.html:

    def form(self):
        return render_response('/form.myt')

    @validate(schema=model.form.EmailForm(), form='form')
    def email(self):
        return Response('Your email is: %s' %
self.form_result.get('email'))

When the email address is missing an at-sign, I get this message: Eine
E-mail Adresse muß ein einzelnes @ Zeichen enthalten
(Which is, by the way, outdated German, as we now write "muss" instead
of "muß".)

But with the FormBuild code, I get a UnicodeEncodeError. All messages
that contain no non-ascii characters work fine. But the one stated
above (containing 'ß') breaks:

    def email_form(self):
        if len(request.params):
            try:
                results =
model.forms.schema.EmailFormSchema.to_python(
                        dict(request.params),
                        state=c
                        )
            except formencode.Invalid, e:
                c.form = model.forms.build.StandardForm(
                        dict(request.params),
                        e.error_dict or {}
                        )
                return render_response('/email_form.myt')
            else:
                return Response(
                        'Your are %s years old and have the following
email: %s' % (
                                results['age'],
                                results['email']
                                )
                        )
        else:
            c.form = model.forms.build.StandardForm()
            return render_response('/email_form.myt')

This gives me:

Error:  Error(UnicodeEncodeError): 'ascii' codec can't encode character
u'\xdf' in position 22: ordinal not in range(128)
File:   /usr/lib/python2.4/site-packages/FormBuild-0.1.6b-py2.4.egg/
formbuild/builder/layout/basic.py line 21
Context:
18:     <td>"""%(name)
19:
20:     def entry_end(self, name='', error='' ):
21:         return """</td>
22:     <td valign="top">%s</td>
23: </tr>\n"""%(error)
24:

So I thought it might be rather a FormBuild problem than a FormEncode
one. But I might be wrong, anyway.

Thanks for looking into this!

Regards,
Frederik


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to