Commit 26676fb8 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

ERP5Site: add erp5_sql_isolated_connection.

parent 93b3bdc6
...@@ -50,6 +50,7 @@ from Products.ERP5Type.mixin.response_header_generator import ResponseHeaderGene ...@@ -50,6 +50,7 @@ from Products.ERP5Type.mixin.response_header_generator import ResponseHeaderGene
from zLOG import LOG, INFO, WARNING, ERROR from zLOG import LOG, INFO, WARNING, ERROR
from zExceptions import BadRequest from zExceptions import BadRequest
import os import os
import re
import warnings import warnings
import transaction import transaction
from App.config import getConfiguration from App.config import getConfiguration
...@@ -84,6 +85,7 @@ def manage_addERP5Site(self, ...@@ -84,6 +85,7 @@ def manage_addERP5Site(self,
validate_email=0, validate_email=0,
erp5_catalog_storage='erp5_mysql_innodb_catalog', erp5_catalog_storage='erp5_mysql_innodb_catalog',
erp5_sql_connection_string=default_sql_connection_string, erp5_sql_connection_string=default_sql_connection_string,
erp5_sql_read_committed_connection_string=default_sql_connection_string,
cmf_activity_sql_connection_string=default_sql_connection_string, cmf_activity_sql_connection_string=default_sql_connection_string,
bt5_repository_url='', bt5_repository_url='',
bt5='', bt5='',
...@@ -103,6 +105,7 @@ def manage_addERP5Site(self, ...@@ -103,6 +105,7 @@ def manage_addERP5Site(self,
create_userfolder, create_userfolder,
erp5_catalog_storage, erp5_catalog_storage,
erp5_sql_connection_string, erp5_sql_connection_string,
erp5_sql_read_committed_connection_string,
cmf_activity_sql_connection_string, cmf_activity_sql_connection_string,
bt5_repository_url, bt5_repository_url,
bt5, bt5,
...@@ -2114,6 +2117,7 @@ class ERP5Generator(PortalGenerator): ...@@ -2114,6 +2117,7 @@ class ERP5Generator(PortalGenerator):
create_userfolder, create_userfolder,
erp5_catalog_storage, erp5_catalog_storage,
erp5_sql_connection_string, erp5_sql_connection_string,
erp5_sql_read_committed_connection_string,
cmf_activity_sql_connection_string, cmf_activity_sql_connection_string,
bt5_repository_url, bt5_repository_url,
bt5, bt5,
...@@ -2138,11 +2142,13 @@ class ERP5Generator(PortalGenerator): ...@@ -2138,11 +2142,13 @@ class ERP5Generator(PortalGenerator):
# Return the fully wrapped object. # Return the fully wrapped object.
p = parent.this()._getOb(id) p = parent.this()._getOb(id)
erp5_sql_deferred_connection_string = erp5_sql_connection_string erp5_sql_deferred_connection_string = erp5_sql_read_committed_connection_string
p._setProperty('erp5_catalog_storage', p._setProperty('erp5_catalog_storage',
erp5_catalog_storage, 'string') erp5_catalog_storage, 'string')
p._setProperty('erp5_sql_connection_string', p._setProperty('erp5_sql_connection_string',
erp5_sql_connection_string, 'string') erp5_sql_connection_string, 'string')
p._setProperty('erp5_sql_read_committed_connection_string',
erp5_sql_read_committed_connection_string, 'string')
p._setProperty('erp5_sql_deferred_connection_string', p._setProperty('erp5_sql_deferred_connection_string',
erp5_sql_deferred_connection_string, 'string') erp5_sql_deferred_connection_string, 'string')
p._setProperty('cmf_activity_sql_connection_string', p._setProperty('cmf_activity_sql_connection_string',
...@@ -2291,7 +2297,7 @@ class ERP5Generator(PortalGenerator): ...@@ -2291,7 +2297,7 @@ class ERP5Generator(PortalGenerator):
# The only difference compared to activity connection is the # The only difference compared to activity connection is the
# minus prepended to the connection string. # minus prepended to the connection string.
if id == 'erp5_sql_transactionless_connection': if id == 'erp5_sql_transactionless_connection':
connection_string = '-' + p.cmf_activity_sql_connection_string connection_string = re.sub(r'((?:[%*][^ ]+ )*)(![^ ]+ )?(.+)', r'\1-\3', p.cmf_activity_sql_connection_string)
else: else:
connection_string = getattr(p, id + '_string') connection_string = getattr(p, id + '_string')
manage_add(id, title, connection_string, **kw) manage_add(id, title, connection_string, **kw)
...@@ -2302,6 +2308,8 @@ class ERP5Generator(PortalGenerator): ...@@ -2302,6 +2308,8 @@ class ERP5Generator(PortalGenerator):
manage_add = p.manage_addProduct['ZMySQLDA'].manage_addZMySQLConnection manage_add = p.manage_addProduct['ZMySQLDA'].manage_addZMySQLConnection
addSQLConnection('erp5_sql_connection', addSQLConnection('erp5_sql_connection',
'ERP5 SQL Server Connection') 'ERP5 SQL Server Connection')
addSQLConnection('erp5_sql_read_committed_connection',
'ERP5 SQL Server Isolated Connection')
addSQLConnection('erp5_sql_deferred_connection', addSQLConnection('erp5_sql_deferred_connection',
'ERP5 SQL Server Deferred Connection', 'ERP5 SQL Server Deferred Connection',
deferred=True) deferred=True)
...@@ -2603,8 +2611,8 @@ def initialize(self): ...@@ -2603,8 +2611,8 @@ def initialize(self):
from Products.ZMySQLDA.db import DB, OperationalError from Products.ZMySQLDA.db import DB, OperationalError
def addERP5Site(REQUEST): def addERP5Site(REQUEST):
default_kw = inspect.getcallargs(manage_addERP5Site, None, '') default_kw = inspect.getcallargs(manage_addERP5Site, None, '')
db = (kw.get('erp5_sql_connection_string') or db = (kw.get('erp5_sql_read_committed_connection_string') or
default_kw['erp5_sql_connection_string']) default_kw['erp5_sql_read_committed_connection_string'])
# The lock is to avoid that multiple zopes try to create a site when # The lock is to avoid that multiple zopes try to create a site when
# they're started at the same time, because this is a quite long operation # they're started at the same time, because this is a quite long operation
# (-> high probably of conflict with a lot of wasted CPU). # (-> high probably of conflict with a lot of wasted CPU).
......
...@@ -101,6 +101,7 @@ def _getConnectionStringDict(): ...@@ -101,6 +101,7 @@ def _getConnectionStringDict():
connection_string_dict = {} connection_string_dict = {}
default = os.environ.get('erp5_sql_connection_string') default = os.environ.get('erp5_sql_connection_string')
for connection in ('erp5_sql_connection_string', for connection in ('erp5_sql_connection_string',
'erp5_sql_read_committed_connection_string',
'erp5_sql_deferred_connection_string', 'erp5_sql_deferred_connection_string',
# default value for transactionless is derived from value # default value for transactionless is derived from value
# for cmf_activity, so process it last # for cmf_activity, so process it last
...@@ -111,7 +112,7 @@ def _getConnectionStringDict(): ...@@ -111,7 +112,7 @@ def _getConnectionStringDict():
connection = 'erp5_sql_transactionless_connection_string' connection = 'erp5_sql_transactionless_connection_string'
if os.environ.get(connection, connection_string): if os.environ.get(connection, connection_string):
connection_string_dict[connection] = \ connection_string_dict[connection] = \
os.environ.get(connection, '-' + connection_string) os.environ.get(connection, re.sub(r'((?:[%*][^ ]+ )*)(![^ ]+ )?(.+)', r'\1-\3', connection_string))
return connection_string_dict return connection_string_dict
def _getConversionServerUrlList(): def _getConversionServerUrlList():
......
...@@ -58,10 +58,13 @@ Options: ...@@ -58,10 +58,13 @@ Options:
--erp5_sql_connection_string=STRING --erp5_sql_connection_string=STRING
ZSQL Connection string for erp5_sql_connection, by ZSQL Connection string for erp5_sql_connection, by
default, it will use "test test" default, it will use "test test"
--erp5_sql_read_committed_connection_string=STRING
ZSQL Connection string for erp5_sql_read_committed_connection
(if unset, defaults to erp5_sql_connection_string with "!READ-COMMITTED")
--cmf_activity_sql_connection_string=STRING --cmf_activity_sql_connection_string=STRING
ZSQL Connection string for ZSQL Connection string for
cmf_activity_sql_connection (if unset, defaults to cmf_activity_sql_connection (if unset, defaults to
erp5_sql_connection_string) erp5_sql_read_committed_connection_string)
--extra_sql_connection_string_list=STRING --extra_sql_connection_string_list=STRING
Used when 2 or more ZSQL connection strings are Used when 2 or more ZSQL connection strings are
needed. By defaut, it will take the last four needed. By defaut, it will take the last four
...@@ -744,6 +747,7 @@ def main(argument_list=None): ...@@ -744,6 +747,7 @@ def main(argument_list=None):
"firefox_bin=", "firefox_bin=",
"xvfb_bin=", "xvfb_bin=",
"recreate_catalog=", "erp5_sql_connection_string=", "recreate_catalog=", "erp5_sql_connection_string=",
"erp5_sql_read_committed_connection_string=",
"cmf_activity_sql_connection_string=", "cmf_activity_sql_connection_string=",
"extra_sql_connection_string_list=", "extra_sql_connection_string_list=",
"conversion_server_url=", "conversion_server_url=",
...@@ -824,6 +828,8 @@ def main(argument_list=None): ...@@ -824,6 +828,8 @@ def main(argument_list=None):
os.environ["erp5_tests_recreate_catalog"] = arg os.environ["erp5_tests_recreate_catalog"] = arg
elif opt == "--erp5_sql_connection_string": elif opt == "--erp5_sql_connection_string":
os.environ["erp5_sql_connection_string"] = arg os.environ["erp5_sql_connection_string"] = arg
elif opt == "--erp5_sql_read_committed_connection_string":
os.environ["erp5_sql_read_committed_connection_string"] = arg
elif opt == "--cmf_activity_sql_connection_string": elif opt == "--cmf_activity_sql_connection_string":
os.environ["cmf_activity_sql_connection_string"] = arg os.environ["cmf_activity_sql_connection_string"] = arg
elif opt == "--extra_sql_connection_string_list": elif opt == "--extra_sql_connection_string_list":
...@@ -898,6 +904,12 @@ def main(argument_list=None): ...@@ -898,6 +904,12 @@ def main(argument_list=None):
elif opt == "--with_wendelin_core": elif opt == "--with_wendelin_core":
os.environ["with_wendelin_core"] = "1" os.environ["with_wendelin_core"] = "1"
if "erp5_sql_read_committed_connection_string" not in os.environ and "erp5_sql_connection_string" in os.environ:
os.environ["erp5_sql_read_committed_connection_string"] = re.sub(
r'((?:[%*][^ ]+ )*)(![^ ]+ )?(.+)', r'\1!READ-COMMITTED \3', os.environ["erp5_sql_connection_string"])
if "cmf_activity_sql_connection_string" not in os.environ and "erp5_sql_read_committed_connection_string" in os.environ:
os.environ["cmf_activity_sql_connection_string"] = os.environ["erp5_sql_read_committed_connection_string"]
bt5_path_list += filter(None, bt5_path_list += filter(None,
os.environ.get("erp5_tests_bt5_path", "").split(',')) os.environ.get("erp5_tests_bt5_path", "").split(','))
valid_path_list = [] valid_path_list = []
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment