request encoding in five.formlib

Bug #751586 reported by samuel or tell me sam on 2011-04-05
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
five.formlib
Undecided
Unassigned

Bug Description

hi all,

I use five.formlib with plone 4. i found that the request is transformed to unicode but never restored at the end of rendering a template. If some code depends on the request after rendering the formlib template it will break.

All in all this seems dangerous to me, is there another way to accomplish this?

Regards, sam
Raptus AG

the following hack works for me, but looks ugly:

--- src/five.formlib/src/five/formlib/formbase.py (revision 121284)
+++ src/five.formlib/src/five/formlib/formbase.py (working copy)
@@ -47,10 +47,15 @@
         # BBB: for CMFDefault < 2.3 (explicit charset required)
         self.request.RESPONSE.setHeader('Content-Type',
             'text/html; charset=%s' % HTTPRequest.default_encoding)
+
+ # only change a copy from form to unicode and restore it at the end.
+ old_request_form = self.request.form
+ self.request.form = self.request.form.copy()
         # BBB: for Zope < 2.14
         if not getattr(self.request, 'postProcessInputs', False):
             processInputs(self.request, [HTTPRequest.default_encoding])
         super(FiveFormlibMixin, self).update()
+ self.request.form = old_request_form

 class FormBase(FiveFormlibMixin, form.FormBase):

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers