diff sat_pubsub/pgsql_storage.py @ 270:f17034e4cf4a

fixed unicode handling with psycopg2
author Goffi <goffi@goffi.org>
date Wed, 13 Aug 2014 17:01:29 +0200
parents 89493845d3dd
children 232002e132db
line wrap: on
line diff
--- a/sat_pubsub/pgsql_storage.py	Wed Aug 13 17:01:08 2014 +0200
+++ b/sat_pubsub/pgsql_storage.py	Wed Aug 13 17:01:29 2014 +0200
@@ -64,6 +64,9 @@
 
 from sat_pubsub import error, iidavoll, const
 import psycopg2
+import psycopg2.extensions
+psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
+psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY)
 
 class Storage:
 
@@ -88,7 +91,6 @@
     def __init__(self, dbpool):
         self.dbpool = dbpool
 
-
     def getNode(self, nodeIdentifier):
         return self.dbpool.runInteraction(self._getNode, nodeIdentifier)
 
@@ -408,7 +410,7 @@
 
         subscriptions = []
         for row in rows:
-            subscriber = jid.JID('%s/%s' % (row[0], row[1]))
+            subscriber = jid.JID(u'%s/%s' % (row[0], row[1]))
 
             options = {}
             if row[3]: