request encoding in five.formlib

Bug #751586 reported by samuel or tell me sam
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
five.formlib
Invalid
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):

Revision history for this message
Colin Watson (cjwatson) wrote :

The five.formlib project on Launchpad has been archived at the request of the Zope developers (see https://answers.launchpad.net/launchpad/+question/683589 and https://answers.launchpad.net/launchpad/+question/685285). If this bug is still relevant, please refile it at https://github.com/zopefoundation/five.formlib.

Changed in five.formlib:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.