Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
Kirill Smelkov
ZODB
Commits
bfad323e
Commit
bfad323e
authored
Aug 27, 2004
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Raise ConnectionStateError if an attempt to close a connection
is made while the connection has a pending subtransaction.
parent
c9da918d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
2 deletions
+56
-2
NEWS.txt
NEWS.txt
+14
-0
src/ZODB/Connection.py
src/ZODB/Connection.py
+6
-0
src/ZODB/tests/testConnection.py
src/ZODB/tests/testConnection.py
+36
-2
No files found.
NEWS.txt
View file @
bfad323e
...
...
@@ -2,6 +2,20 @@ What's new in ZODB3 3.3 ?
=========================
Release date: DD-MMM-YYYY
Connection
----------
ZODB intends to raise ConnnectionStateError if an attempt is made to
close a connection while modifications are pending (the connection is
involved in a transaction that hasn't been abort()'ed or commit()'ed).
It was missing the case where the only pending modifications were made
in subtransactions. This has been fixed. If an attempt to close a
connection with pending subtransactions is made now,
ConnnectionStateError: Cannot close a connection with a pending subtransaction
is raised.
transaction
-----------
...
...
src/ZODB/Connection.py
View file @
bfad323e
...
...
@@ -540,6 +540,12 @@ class Connection(ExportImport, object):
raise
ConnectionStateError
(
"Cannot close a connection joined to "
"a transaction"
)
if
self
.
_tmp
is
not
None
:
# There are no direct modifications pending, but a subtransaction
# is pending.
raise
ConnectionStateError
(
"Cannot close a connection with a "
"pending subtransaction"
)
if
self
.
_cache
is
not
None
:
self
.
_cache
.
incrgc
()
# This is a good time to do some GC
...
...
src/ZODB/tests/testConnection.py
View file @
bfad323e
...
...
@@ -264,7 +264,7 @@ class UserMethodTests(unittest.TestCase):
>>> transaction.commit()
>>> cn.close()
Opening, making a change,
committing,
and aborting is fine.
Opening, making a change, and aborting is fine.
>>> cn = db.open()
>>> cn.root()['a'] = 1
>>> transaction.abort()
...
...
@@ -272,7 +272,7 @@ class UserMethodTests(unittest.TestCase):
But trying to close with a change pending complains.
>>> cn = db.open()
>>> cn.root()['a'] = 1
>>> cn.root()['a'] = 1
0
>>> cn.close()
Traceback (most recent call last):
...
...
...
@@ -281,7 +281,41 @@ class UserMethodTests(unittest.TestCase):
This leaves the connection as it was, so we can still commit
the change.
>>> transaction.commit()
>>> cn2 = db.open()
>>> cn2.root()['a']
10
>>> cn.close(); cn2.close()
Bug: We weren't catching the case where the only changes pending
were in a subtransaction.
>>> cn = db.open()
>>> cn.root()['a'] = 100
>>> transaction.commit(True)
>>> cn.close() # this was succeeding
Traceback (most recent call last):
...
ConnectionStateError: Cannot close a connection with a pending subtransaction
Again this leaves the connection as it was.
>>> transaction.commit()
>>> cn2 = db.open()
>>> cn2.root()['a']
100
>>> cn.close(); cn2.close()
Make sure we can still close a connection after aborting a pending
subtransaction.
>>> cn = db.open()
>>> cn.root()['a'] = 1000
>>> transaction.commit(True)
>>> cn.root()['a']
1000
>>> transaction.abort()
>>> cn.root()['a']
100
>>> cn.close()
>>> db.close()
"""
def
test_onCloseCallbacks
(
self
):
...
...
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