[google-appengine] Re: UnicodeDecodeError in Appengine deployed version, but not in Devserver

2011-03-23 Thread Geoffrey Spear
I can't imagine why this would work on the dev server (might be a
locale setting on your local machine that makes unicode() somehow use
an encoding that works), but from what I can tell, an ARC4
object's .encrypt() method isn't producing encoded unicode, so
coercing it to unicode (either without specifying an encoding or with
one) should fail spectacularly.  Use a db.BlobProperty to store binary
data, rather than trying to convert it to unicode and storing it as
text.

On Mar 22, 7:51 pm, Kwame iweg...@gmail.com wrote:
 Sure Geoffrey. Sorry about that.

 class Person(db.model):
   name = db.StringProperty()
   description = db.TextProperty()

 class PersonHandler(webapp.RequestHandler):
   def get(self):
     pers = Person()
     pers.name = unicode(encrypt_data(self.request.get('name')))
     pers.description =
 unicode(encrypt_data(self.request.get('description')))
     pers.put()

 def encrypt_data(plaintext):
     obj=ARC4.new(RSAPrivateKey())
     return obj.encrypt(plaintext)

 def decrypt_data(ciphertext):
     obj=ARC4.new(RSAPrivateKey())
     return obj.decrypt(ciphertext)

 #

 This code properly encrypts/decrypts the webapp request variables and
 stores into the Person Object while running on the localhost Dev
 server, but on the Deployed app, it throws a UnicodeDecodeError. I've
 also tried:

 unicode(encrypt_data(self.request.get('description'))).encode('utf-8')
 but that fails on both servers

 On Mar 22, 1:25 pm, Geoffrey Spear geoffsp...@gmail.com wrote:







  On Mar 22, 12:45 pm, Kwame iweg...@gmail.com wrote:

   'ascii' codec can't decode byte 0x8a in position 2: ordinal not in
   range(128)

   I've read so many solutions about this problem, even Nick's 
   Blog:http://blog.notdot.net/2010/07/Getting-unicode-right-in-Python

   ...which addresses the problem very well. So I've been able to resolve
   this unicode issue on GAE devserver, however I continue to experience
   it on my live deployed version. This makes no sense to me. Can anyone
   help??

  Without seeing your code, almost certainly not.

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



[google-appengine] Re: UnicodeDecodeError in Appengine deployed version, but not in Devserver

2011-03-23 Thread Kwame
Thanks! It works now. For others reading this thread, the code now
reads:

class Person(db.model):
  name = db.ByteString()
  description = db.BlobProperty()

class PersonHandler(webapp.RequestHandler):
  def get(self):
pers = Person()
pers.name = encrypt_data(self.request.get('name'))
pers.description = encrypt_data(self.request.get('description'))
pers.put()

def encrypt_data(plaintext):
obj=ARC4.new(RSAPrivateKey())
return obj.encrypt(plaintext)

def decrypt_data(ciphertext):
obj=ARC4.new(RSAPrivateKey())
return obj.decrypt(ciphertext)

On Mar 23, 1:12 pm, Geoffrey Spear geoffsp...@gmail.com wrote:
 I can't imagine why this would work on the dev server (might be a
 locale setting on your local machine that makes unicode() somehow use
 an encoding that works), but from what I can tell, an ARC4
 object's .encrypt() method isn't producing encoded unicode, so
 coercing it to unicode (either without specifying an encoding or with
 one) should fail spectacularly.  Use a db.BlobProperty to store binary
 data, rather than trying to convert it to unicode and storing it as
 text.

 On Mar 22, 7:51 pm, Kwame iweg...@gmail.com wrote:







  Sure Geoffrey. Sorry about that.

  class Person(db.model):
    name = db.StringProperty()
    description = db.TextProperty()

  class PersonHandler(webapp.RequestHandler):
    def get(self):
      pers = Person()
      pers.name = unicode(encrypt_data(self.request.get('name')))
      pers.description =
  unicode(encrypt_data(self.request.get('description')))
      pers.put()

  def encrypt_data(plaintext):
      obj=ARC4.new(RSAPrivateKey())
      return obj.encrypt(plaintext)

  def decrypt_data(ciphertext):
      obj=ARC4.new(RSAPrivateKey())
      return obj.decrypt(ciphertext)

  #

  This code properly encrypts/decrypts the webapp request variables and
  stores into the Person Object while running on the localhost Dev
  server, but on the Deployed app, it throws a UnicodeDecodeError. I've
  also tried:

  unicode(encrypt_data(self.request.get('description'))).encode('utf-8')
  but that fails on both servers

  On Mar 22, 1:25 pm, Geoffrey Spear geoffsp...@gmail.com wrote:

   On Mar 22, 12:45 pm, Kwame iweg...@gmail.com wrote:

'ascii' codec can't decode byte 0x8a in position 2: ordinal not in
range(128)

I've read so many solutions about this problem, even Nick's 
Blog:http://blog.notdot.net/2010/07/Getting-unicode-right-in-Python

...which addresses the problem very well. So I've been able to resolve
this unicode issue on GAE devserver, however I continue to experience
it on my live deployed version. This makes no sense to me. Can anyone
help??

   Without seeing your code, almost certainly not.

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



[google-appengine] Re: UnicodeDecodeError in Appengine deployed version, but not in Devserver

2011-03-22 Thread Geoffrey Spear


On Mar 22, 12:45 pm, Kwame iweg...@gmail.com wrote:
 'ascii' codec can't decode byte 0x8a in position 2: ordinal not in
 range(128)

 I've read so many solutions about this problem, even Nick's 
 Blog:http://blog.notdot.net/2010/07/Getting-unicode-right-in-Python

 ...which addresses the problem very well. So I've been able to resolve
 this unicode issue on GAE devserver, however I continue to experience
 it on my live deployed version. This makes no sense to me. Can anyone
 help??

Without seeing your code, almost certainly not.

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



[google-appengine] Re: UnicodeDecodeError in Appengine deployed version, but not in Devserver

2011-03-22 Thread Kwame
Sure Geoffrey. Sorry about that.

class Person(db.model):
  name = db.StringProperty()
  description = db.TextProperty()


class PersonHandler(webapp.RequestHandler):
  def get(self):
pers = Person()
pers.name = unicode(encrypt_data(self.request.get('name')))
pers.description =
unicode(encrypt_data(self.request.get('description')))
pers.put()


def encrypt_data(plaintext):
obj=ARC4.new(RSAPrivateKey())
return obj.encrypt(plaintext)


def decrypt_data(ciphertext):
obj=ARC4.new(RSAPrivateKey())
return obj.decrypt(ciphertext)

#

This code properly encrypts/decrypts the webapp request variables and
stores into the Person Object while running on the localhost Dev
server, but on the Deployed app, it throws a UnicodeDecodeError. I've
also tried:

unicode(encrypt_data(self.request.get('description'))).encode('utf-8')
but that fails on both servers



On Mar 22, 1:25 pm, Geoffrey Spear geoffsp...@gmail.com wrote:
 On Mar 22, 12:45 pm, Kwame iweg...@gmail.com wrote:

  'ascii' codec can't decode byte 0x8a in position 2: ordinal not in
  range(128)

  I've read so many solutions about this problem, even Nick's 
  Blog:http://blog.notdot.net/2010/07/Getting-unicode-right-in-Python

  ...which addresses the problem very well. So I've been able to resolve
  this unicode issue on GAE devserver, however I continue to experience
  it on my live deployed version. This makes no sense to me. Can anyone
  help??

 Without seeing your code, almost certainly not.

-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.