Adding patch from Timothy E. Harris <maintainer@mepiscommunity.org> to prevents creating a new database if the locale is not a UTF-8 one (Closes: #584976).

bzr revid: p_christ@hol.gr-20101019095657-36xhp4ihkvhf5n9h
This commit is contained in:
Daniel Baumann 2010-10-19 12:56:57 +03:00 committed by P. Christeas
parent 7732b7f40c
commit 248984ad5c
2 changed files with 34 additions and 0 deletions

33
debian/patches/05-db-encoding.patch vendored Normal file
View File

@ -0,0 +1,33 @@
Author: Timothy E. Harris <maintainer@mepiscommunity.org>
Description:
Fix bug that prevents creating a new database if the locale is not a UTF-8 one
(Closes: #584976).
diff -Naurp openerp-server.orig/bin/service/web_services.py openerp-server/bin/service/web_services.py
--- openerp-server.orig/bin/service/web_services.py 2010-03-30 11:24:21.000000000 +0000
+++ openerp-server/bin/service/web_services.py 2010-06-08 09:39:10.000000000 +0000
@@ -38,6 +38,7 @@ import release
import sql_db
import tools
import locale
+import re
from cStringIO import StringIO
logging.basicConfig()
@@ -64,11 +65,15 @@ class db(netsvc.Service):
self._pg_psw_env_var_is_set = False # on win32, pg_dump need the PGPASSWORD env var
def _create_empty_database(self, name):
+ if re.search('utf|UTF', locale.getdefaultlocale()[1]):
+ db_encoding = 'unicode'
+ else:
+ db_encoding = 'LATIN1'
db = sql_db.db_connect('template1')
cr = db.cursor()
try:
cr.autocommit(True) # avoid transaction block
- cr.execute("""CREATE DATABASE "%s" ENCODING 'unicode' TEMPLATE "template0" """ % name)
+ cr.execute("""CREATE DATABASE "%s" ENCODING '%s' TEMPLATE "template0" """ %(name, db_encoding))
finally:
cr.close()

View File

@ -2,3 +2,4 @@
02-migrate.patch
03-shebang.patch
04-manpage.patch
05-db-encoding.patch