34 lines
1.3 KiB
Diff
34 lines
1.3 KiB
Diff
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()
|
|
|