Permalink
Browse files

fix for postgres unicode bug (Bug#177265)

  • Loading branch information...
1 parent e3b2276 commit 2fb8483d537276123859f0705f57d49ebf486db7 @anandology anandology committed Dec 27, 2007
Showing with 10 additions and 1 deletion.
  1. +10 −1 web/db.py
View
@@ -260,6 +260,10 @@ def connect(dbn, **keywords):
if dbn == "postgres":
try:
import psycopg2 as db
+
+ # fix for Bug#177265
+ import psycopg2.extensions
+ psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
except ImportError:
try:
import psycopg as db
@@ -324,7 +328,12 @@ def db_cursor():
globals()['db'] = _PooledDB(db, keywords)
web.ctx.db = globals()['db'].connection()
else:
- web.ctx.db = db.connect(**keywords)
+ web.ctx.db = db.connect(**keywords)
+
+ # fix for Bug#177265
+ if web.ctx.get('db_name') == "postgres":
+ web.ctx.db.set_client_encoding('UTF8')
+
return web.ctx.db.cursor()
web.ctx.db_cursor = db_cursor

0 comments on commit 2fb8483

Please sign in to comment.