Commit f8633566 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

ERP5Site: add erp5_sql_read_committed_connection.

parent cf2107a1
...@@ -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,7 +85,7 @@ def manage_addERP5Site(self, ...@@ -84,7 +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,
cmf_activity_sql_connection_string=default_sql_connection_string, cmf_activity_sql_connection_string='!READ-COMMITTED %s' % default_sql_connection_string,
bt5_repository_url='', bt5_repository_url='',
bt5='', bt5='',
id_store_interval='', id_store_interval='',
...@@ -2291,7 +2292,9 @@ class ERP5Generator(PortalGenerator): ...@@ -2291,7 +2292,9 @@ 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)
elif id == 'erp5_sql_read_committed_connection':
connection_string = re.sub(r'((?:[%*][^ ]+ )*)(![^ ]+ )?(.+)', r'\1!READ-COMMITTED \3', p.erp5_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 +2305,8 @@ class ERP5Generator(PortalGenerator): ...@@ -2302,6 +2305,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)
......
...@@ -101,17 +101,20 @@ def _getConnectionStringDict(): ...@@ -101,17 +101,20 @@ 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_deferred_connection_string', 'erp5_sql_deferred_connection_string'):
# default value for transactionless is derived from value
# for cmf_activity, so process it last
'cmf_activity_sql_connection_string'):
connection_string = os.environ.get(connection, default) connection_string = os.environ.get(connection, default)
if connection_string: if connection_string:
connection_string_dict[connection] = connection_string connection_string_dict[connection] = connection_string
connection = 'cmf_activity_sql_connection_string'
connection_string_dict[connection] = \
os.environ.get(connection, re.sub(
r'((?:[%*][^ ]+ )*)(![^ ]+ )?(.+)', r'\1!READ-COMMITTED \3', connection_string_dict['erp5_sql_connection_string']))
# default value for transactionless is derived from value
# for cmf_activity, so process it last
connection = 'erp5_sql_transactionless_connection_string' connection = 'erp5_sql_transactionless_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_dict['cmf_activity_sql_connection_string']))
return connection_string_dict return connection_string_dict
def _getConversionServerUrlList(): def _getConversionServerUrlList():
......
...@@ -61,7 +61,7 @@ Options: ...@@ -61,7 +61,7 @@ Options:
--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_connection_string with "!READ-COMMITTED")
--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
......
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