Mercurial > libervia-pubsub
comparison 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 |
comparison
equal
deleted
inserted
replaced
269:9df844d9d5ac | 270:f17034e4cf4a |
---|---|
62 from wokkel.generic import parseXml, stripNamespace | 62 from wokkel.generic import parseXml, stripNamespace |
63 from wokkel.pubsub import Subscription | 63 from wokkel.pubsub import Subscription |
64 | 64 |
65 from sat_pubsub import error, iidavoll, const | 65 from sat_pubsub import error, iidavoll, const |
66 import psycopg2 | 66 import psycopg2 |
67 import psycopg2.extensions | |
68 psycopg2.extensions.register_type(psycopg2.extensions.UNICODE) | |
69 psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY) | |
67 | 70 |
68 class Storage: | 71 class Storage: |
69 | 72 |
70 implements(iidavoll.IStorage) | 73 implements(iidavoll.IStorage) |
71 | 74 |
85 } | 88 } |
86 } | 89 } |
87 | 90 |
88 def __init__(self, dbpool): | 91 def __init__(self, dbpool): |
89 self.dbpool = dbpool | 92 self.dbpool = dbpool |
90 | |
91 | 93 |
92 def getNode(self, nodeIdentifier): | 94 def getNode(self, nodeIdentifier): |
93 return self.dbpool.runInteraction(self._getNode, nodeIdentifier) | 95 return self.dbpool.runInteraction(self._getNode, nodeIdentifier) |
94 | 96 |
95 def _getNode(self, cursor, nodeIdentifier): | 97 def _getNode(self, cursor, nodeIdentifier): |
406 cursor.execute(query, values); | 408 cursor.execute(query, values); |
407 rows = cursor.fetchall() | 409 rows = cursor.fetchall() |
408 | 410 |
409 subscriptions = [] | 411 subscriptions = [] |
410 for row in rows: | 412 for row in rows: |
411 subscriber = jid.JID('%s/%s' % (row[0], row[1])) | 413 subscriber = jid.JID(u'%s/%s' % (row[0], row[1])) |
412 | 414 |
413 options = {} | 415 options = {} |
414 if row[3]: | 416 if row[3]: |
415 options['pubsub#subscription_type'] = row[3]; | 417 options['pubsub#subscription_type'] = row[3]; |
416 if row[4]: | 418 if row[4]: |