Browse files

Changed blob encoder/decoder to work via base64 which eliminates mysq…

…l 1366 (invalid characters) problem and allows to store blobs correctly.
  • Loading branch information...
1 parent 453a00b commit 256b5ef446fcf25d4d85bbeac6d0e1838b71a4d7 Gregory Sitnin committed Sep 14, 2011
Showing with 7 additions and 6 deletions.
  1. +7 −6 openid/store/sqlstore.py
View
13 openid/store/sqlstore.py
@@ -13,6 +13,8 @@
from openid.store.interface import OpenIDStore
from openid.store import nonce
+from base64 import b64encode, b64decode
+
def _inTxn(func):
def wrapped(self, *args, **kwargs):
return self._callInTransaction(func, self, *args, **kwargs)
@@ -414,12 +416,11 @@ class MySQLStore(SQLStore):
clean_nonce_sql = 'DELETE FROM %(nonces)s WHERE timestamp < %%s;'
def blobDecode(self, blob):
- if type(blob) is str:
- # Versions of MySQLdb >= 1.2.2
- return blob
- else:
- # Versions of MySQLdb prior to 1.2.2 (as far as we can tell)
- return blob.tostring()
+ return b64decode(blob)
+
+ def blobEncode(self, s):
+ return b64encode(s)
+
class PostgreSQLStore(SQLStore):
"""

0 comments on commit 256b5ef

Please sign in to comment.