[snowy] Fix the longstanding python 2.7 bug



commit 7787cea4e488b2593d229c6d0252799de7b7344c
Author: Jeff Schroeder <jeffschroeder computer org>
Date:   Sun May 8 20:46:05 2011 -0700

    Fix the longstanding python 2.7 bug
    
    Thanks to Blaise Alleyne, ê¹? ë??곤, and:
    http://stackoverflow.com/questions/4341206/requesting-token-via-django-piston-throws-typeerror-exception

 lib/piston/store.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/lib/piston/store.py b/lib/piston/store.py
index 787791a..e6e2bca 100644
--- a/lib/piston/store.py
+++ b/lib/piston/store.py
@@ -13,6 +13,8 @@ class DataStore(oauth.OAuthDataStore):
     def lookup_consumer(self, key):
         try:
             self.consumer = Consumer.objects.get(key=key)
+            self.consumer.key    = self.consumer.key.encode('ascii')
+            self.consumer.secret = self.consumer.secret.encode('ascii')
             return self.consumer
         except Consumer.DoesNotExist:
             return None
@@ -25,6 +27,8 @@ class DataStore(oauth.OAuthDataStore):
         try:
             self.request_token = Token.objects.get(key=token, 
                                                    token_type=token_type)
+            self.request_token.key    = self.request_token.key.encode('ascii')
+            self.request_token.secret = self.request_token.secret.encode('ascii')
             return self.request_token
         except Token.DoesNotExist:
             return None
@@ -72,4 +76,4 @@ class DataStore(oauth.OAuthDataStore):
             self.request_token.verifier = generate_random(VERIFIER_SIZE)
             self.request_token.save()
             return self.request_token
-        return None
\ No newline at end of file
+        return None



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]