Brian Brinegar
unread,Jun 17, 2012, 10:42:16 PM6/17/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pylons-...@googlegroups.com
I have a pyramid 1.2 application which processes donations made via
PayPal using a service called PayPal Instant Payment Notification.
Today, we had a donation from an international user with non-ascii
characters in their last name. PayPal makes a post request to our
server with information about the pyramid view that handles these the
request failed when I tried to access the last name from
request.params.get('last_name')
I believe requests are encoded as windows-1252, not UTF-8, which is
causing this error. Unfortunately, I do not have the option of
changing the encoding method on PayPal's end.
File "/home/mario/webapps/mario_dyn/mario/mario/views/donate.py",
line 241, in donate_ipn
value = request.params.get(key)
File "/home/mario/webapps/mario_dyn/lib/python2.7/UserDict.py", line
168, in get
return self[key]
File "/home/mario/webapps/mario_dyn/lib/python2.7/webob/multidict.py",
line 312, in __getitem__
return self._decode_value(self.multi.__getitem__(self._encode_key(key)))
File "/home/mario/webapps/mario_dyn/lib/python2.7/webob/multidict.py",
line 301, in _decode_value
value = value.decode(self.encoding, self.errors)
File "/home/mario/webapps/mario_dyn/lib/python2.7/encodings/utf_8.py",
line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe5 in position 1:
invalid continuation byte
So, my question is, how do I tell the the request that the request is
encoded windows-1252 not utf-8, or convert it to utf-8 prior to
accessing the params MultiDict.
Thank you,
Brian