Open GoogleCodeExporter opened 9 years ago
It also happens for accented names, or any non-ascii character entered in the
address collection form.
It seems to me that replacing the line in
Products/PloneGetPaid/browser/checkout.py
that reads:
v = unicode(v, encoding='utf8')
with:
if type(v) is not unicode:
v = unicode(v, encoding='utf8')
solves the problem.
Original comment by silviot
on 11 Apr 2009 at 3:51
Attachments:
As Maurits van Rees explained it on his blog in Search forms with zope formlib
and
batching
There is a difference between getting a value from the request or from
request.form
when unicode is involved:
>>> request.form.get('SearchableText')
u'\xff'
>>> request.get('SearchableText')
'\xc3\xbf'
In the class BaseFormView of base.py, adding the 5 lines between the #
def setUpWidgets( self, ignore_request=False ):
self.adapters = self.adapters is not None and self.adapters or {}
# request unicode matters
fieldnames = [x.__name__ for x in self.form_fields]
for key in fieldnames:
value = self.request.form.get(key)
if value is not None and not value == u'':
self.request[key] = value
#
...
solves the problem ...
Thanks Maurits
Original comment by danielle...@gmail.com
on 17 Apr 2010 at 11:54
It seems that it doesn't now happened anymore
with the lines added in browser.checkout
try:
# try to convert to unicode first, because str() of the unicode string may fail
v = unicode(v)
except UnicodeDecodeError:
v = str(v)
but the comment doesn't give a clue of the "why" side... so there is a risk
that this try, except will be stay for ever even if there is no more problem at
the root, IMHO
Original comment by danielle...@gmail.com
on 1 Jan 2011 at 12:28
Original issue reported on code.google.com by
forsber...@gmail.com
on 3 Feb 2008 at 12:05