Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
erp5
Commits
c60fc5a5
Commit
c60fc5a5
authored
Nov 13, 2023
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ZMySQLDA: support isolation level per connector.
parent
07496d63
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
5 deletions
+17
-5
product/ERP5/ERP5Site.py
product/ERP5/ERP5Site.py
+2
-1
product/ERP5Type/tests/ERP5TypeTestCase.py
product/ERP5Type/tests/ERP5TypeTestCase.py
+2
-1
product/ZMySQLDA/connectionAdd.dtml
product/ZMySQLDA/connectionAdd.dtml
+8
-2
product/ZMySQLDA/db.py
product/ZMySQLDA/db.py
+5
-1
No files found.
product/ERP5/ERP5Site.py
View file @
c60fc5a5
...
...
@@ -2291,7 +2291,8 @@ class ERP5Generator(PortalGenerator):
# The only difference compared to activity connection is the
# minus prepended to the connection string.
if
id
==
'erp5_sql_transactionless_connection'
:
connection_string
=
'-'
+
p
.
cmf_activity_sql_connection_string
index
=
[
i
for
i
,
x
in
enumerate
(
p
.
cmf_activity_sql_connection_string
.
split
())
if
not
x
[
0
]
in
(
'%'
,
'*'
,
'!'
)][
0
]
connection_string
=
' '
.
join
(
'-'
+
x
if
i
==
index
else
x
for
i
,
x
in
enumerate
(
p
.
cmf_activity_sql_connection_string
.
split
()))
else
:
connection_string
=
getattr
(
p
,
id
+
'_string'
)
manage_add
(
id
,
title
,
connection_string
,
**
kw
)
...
...
product/ERP5Type/tests/ERP5TypeTestCase.py
View file @
c60fc5a5
...
...
@@ -110,8 +110,9 @@ def _getConnectionStringDict():
connection_string_dict
[
connection
]
=
connection_string
connection
=
'erp5_sql_transactionless_connection_string'
if
os
.
environ
.
get
(
connection
,
connection_string
):
index
=
[
i
for
i
,
x
in
enumerate
(
connection_string
.
split
())
if
not
x
[
0
]
in
(
'%'
,
'*'
,
'!'
)][
0
]
connection_string_dict
[
connection
]
=
\
os
.
environ
.
get
(
connection
,
'-'
+
connection_string
)
connection_string
=
' '
.
join
(
'-'
+
x
if
i
==
index
else
x
for
i
,
x
in
enumerate
(
connection_string
.
split
())
)
return
connection_string_dict
def
_getConversionServerUrlList
():
...
...
product/ZMySQLDA/connectionAdd.dtml
View file @
c60fc5a5
...
...
@@ -56,7 +56,7 @@
<dd>
The connection string used for Z MySQL Database Connection is of the form:
<br />
<code>[%ssl_name] [*lock] [+/-][database][@host[:port]] [user [password [unix_socket]]]</code>
<code>[%ssl_name] [*lock] [
!isolation-level] [
+/-][database][@host[:port]] [user [password [unix_socket]]]</code>
<br />
or typically:
<br />
...
...
@@ -103,6 +103,12 @@
you'll get an error in the logs, and inconsistent data. In this
respect, it's equivalent to transactions turned off.
</dd>
<dd>
!<em>isolation_level</em> at the begining of the connection string
will set the transaction isolation level in each transaction. The
value should be one of REPEATABLE-READ, READ-COMMITTED,
READ-UNCOMMITTED or SERIALIZABLE.
</dd>
<dd>
Transactions are highly recommended. Using a named lock in
conjunctions with transactions is probably pointless.
...
...
@@ -111,4 +117,4 @@
</main>
<dtml-var manage_page_footer>
\ No newline at end of file
<dtml-var manage_page_footer>
product/ZMySQLDA/db.py
View file @
c60fc5a5
...
...
@@ -242,7 +242,7 @@ class DB(TM):
self._use_TM = transactional or self._mysql_lock
def _parse_connection_string(self):
self._mysql_lock = self._try_transactions = None
self._mysql_lock = self._try_transactions =
self._isolation_level =
None
self._kw_args = kwargs = {'
conv
': self.conv}
items = self._connection.split()
if not items:
...
...
@@ -260,6 +260,8 @@ class DB(TM):
del items[0]
if items[0][0] == "*":
self._mysql_lock = items.pop(0)[1:]
if items[0][0] == "!":
self._isolation_level = items.pop(0)[1:]
db = items.pop(0)
if '
@
' in db:
db, host = db.split('
@
', 1)
...
...
@@ -489,6 +491,8 @@ class DB(TM):
try
:
self
.
_transaction_begun
=
True
if
self
.
_transactions
:
if
self
.
_isolation_level
:
self
.
_query
(
"SET TRANSACTION ISOLATION LEVEL %s"
%
self
.
_isolation_level
.
replace
(
'-'
,
' '
))
self
.
_query
(
"BEGIN"
,
allow_reconnect
=
True
)
if
self
.
_mysql_lock
:
self
.
_query
(
"SELECT GET_LOCK('%s',0)"
%
self
.
_mysql_lock
,
allow_reconnect
=
not
self
.
_transactions
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment