Hallo,
I have modified the Guestbook sample application to allow the
submission of comments via file upload.
Instaed of the user typing directly a comment, he/she can select a
file containing a comment.
This works fine until I have non ascii within the uploaded comment,
for instance ΓΌ.
I then get the following error message
Traceback (most recent call last):
File "C:\Program Files\Google\google_appengine\google\appengine\ext
\webapp\__init__.py", line 500, in __call__
handler.post(*groups)
File "D:\Workspace\guestbook_10312008\guestbook6_templates.py", line
57, in post
greeting.put()
File "C:\Program Files\Google\google_appengine\google\appengine\ext
\db\__init__.py", line 669, in put
return datastore.Put(self._entity)
File "C:\Program Files\Google\google_appengine\google\appengine\api
\datastore.py", line 155, in Put
req.entity_list().extend([e._ToPb() for e in entities])
File "C:\Program Files\Google\google_appengine\google\appengine\api
\datastore.py", line 487, in _ToPb
properties = datastore_types.ToPropertyPb(name, values)
File "C:\Program Files\Google\google_appengine\google\appengine\api
\datastore_types.py", line 1285, in ToPropertyPb
pbvalue = pack_prop(name, v, pb.mutable_value())
File "C:\Program Files\Google\google_appengine\google\appengine\api
\datastore_types.py", line 1123, in PackString
pbvalue.set_stringvalue(unicode(value).encode('utf-8'))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xfc in position
8: ordinal not in range(128)
The 2 modifications I have done to the Guestbook code are as follows:
To index.html I added the following form:
<form action="/upload" method="post" enctype="multipart/form-
data">
<input type="file" name="content">
<div><input type="submit" value="Import"></div>
</form>
To guestbook6_templates.py I added the following class and extended
the webapp.WSGIApplication:
class GuestbookUploaded(webapp.RequestHandler):
def post(self):
greeting = Greeting()
if users.get_current_user():
greeting.author = users.get_current_user()
greeting.content = self.request.get('content')
greeting.put()
self.redirect('/')
application = webapp.WSGIApplication(
[('/', MainPage),
('/sign', Guestbook),
('/upload', GuestbookUploaded),
],
debug=True)
Does anyone know how I can get this to work for non ascii character
sets?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---