[prev in list] [next in list] [prev in thread] [next in thread] 

List:       zope-dev
Subject:    Re: [Zope-dev] [Zope-CMF] Weird UnicodeDecodeError with zope.formlib
From:       "Charlie Clark" <charlie.clark () clark-consulting ! eu>
Date:       2012-12-02 15:08:44
Message-ID: op.woo20u1a5mynk9 () fuchsia ! fritz ! box
[Download RAW message or body]

Am 30.11.2012, 18:21 Uhr, schrieb Charlie Clark  
<charlie.clark@clark-consulting.eu>:

> Let me explain: in pdb I have access to request.form which is where I  
> can see the difference. With Sentry I can only see the raw body of the  
> request. I may simply have not understood well enough how to use it to  
> inspect what's happening.
>  I raise an exception in both cases in the forms' validate method.
>  Do you see this until you extract it first from the request object?
>   You are not having one form saying fieldname:string and the other just
> fieldname?
>  No, they are all zope.formlib/zope.schema fields so there is no  
> additional marshalling.

I have finally tracked down the problem: I seem to have been bitten by a  
change in zope.formlib 4.1.

There are two solutions: either extend a form's update method with the  
something like the following:

    def update(self):
	from Products.Five.browser.decode import processInputs
	from ZPublisher import HTTPRequest
         # XXX: if we don't set default_encoding explicitly, main_template  
might
         #      set a different charset
         self.request.RESPONSE.setHeader('Content-Type',
             'text/html; charset=%s' % HTTPRequest.default_encoding)
         # BBB: for Zope < 2.14
         if not getattr(self.request, 'postProcessInputs', False):
             processInputs(self.request, [HTTPRequest.default_encoding])
         super(_EditFormMixin, self).update()

Or, more simply, base forms on those provided by five.formlib.formbase

Thanks to yuppie for fixing this in the CMF.

I can confirm that this also works with Internet Explorer.

Charlie
-- 
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Kronenstr. 27a
Düsseldorf
D- 40217
Tel: +49-211-600-3657
Mobile: +49-178-782-6226
_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic