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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
ZODB
Commits
28dd6d89
Commit
28dd6d89
authored
Jul 11, 2005
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge rev 33265 from 3.4 branch.
English repairs.
parent
547eb6c5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
18 deletions
+15
-18
src/ZODB/tests/testConnectionSavepoint.txt
src/ZODB/tests/testConnectionSavepoint.txt
+5
-6
src/transaction/savepoint.txt
src/transaction/savepoint.txt
+10
-12
No files found.
src/ZODB/tests/testConnectionSavepoint.txt
View file @
28dd6d89
...
@@ -39,13 +39,13 @@ and abort changes:
...
@@ -39,13 +39,13 @@ and abort changes:
>>> root['name']
>>> root['name']
'bob'
'bob'
Now, lets look at an application that manages funds for people.
Now, let
'
s look at an application that manages funds for people.
It allows deposits and debits to be entered for multiple people.
It allows deposits and debits to be entered for multiple people.
It accepts a sequence of entries and generates a sequence of status
It accepts a sequence of entries and generates a sequence of status
messages. For each entry, it applies the change and then validates
messages. For each entry, it applies the change and then validates
the user's account. If the user's account is invalid, we rol
e
back
the user's account. If the user's account is invalid, we rol
l
back
the change for that entry. The success or failure of an entry is
the change for that entry. The success or failure of an entry is
indicated in the output status. First we'll initialize some accounts:
indicated in the output status.
First we'll initialize some accounts:
>>> root['bob-balance'] = 0.0
>>> root['bob-balance'] = 0.0
>>> root['bob-credit'] = 0.0
>>> root['bob-credit'] = 0.0
...
@@ -60,8 +60,7 @@ Now, we'll define a validation function to validate an account:
...
@@ -60,8 +60,7 @@ Now, we'll define a validation function to validate an account:
... raise ValueError('Overdrawn', name)
... raise ValueError('Overdrawn', name)
And a function to apply entries. If the function fails in some
And a function to apply entries. If the function fails in some
unexpected way, it rolls back all of it's changes and
unexpected way, it rolls back all of its changes and prints the error:
prints the error:
>>> def apply_entries(entries):
>>> def apply_entries(entries):
... savepoint = transaction.savepoint()
... savepoint = transaction.savepoint()
...
@@ -103,7 +102,7 @@ Now let's try applying some entries:
...
@@ -103,7 +102,7 @@ Now let's try applying some entries:
>>> root['sally-balance']
>>> root['sally-balance']
-80.0
-80.0
If we
give
provide entries that cause an unexpected error:
If we provide entries that cause an unexpected error:
>>> apply_entries([
>>> apply_entries([
... ('bob', 10.0),
... ('bob', 10.0),
...
...
src/transaction/savepoint.txt
View file @
28dd6d89
...
@@ -18,13 +18,12 @@ Applications
...
@@ -18,13 +18,12 @@ Applications
To demonstrate how savepoints work with transactions, we've provided a
To demonstrate how savepoints work with transactions, we've provided a
sample data manager implementation that provides savepoint support.
sample data manager implementation that provides savepoint support.
The primary purpose of this data manager is to provide code that can
The primary purpose of this data manager is to provide code that can
be read to understand how savepoints work. The secondary purpose is to
be read to understand how savepoints work.
The secondary purpose is to
provide support for demonstrating the correct operation of savepoint
provide support for demonstrating the correct operation of savepoint
support within the transaction system. This data manager is very
support within the transaction system. This data manager is very
simple. It provides flat storage of named immutable values, like strings
simple. It provides flat storage of named immutable values, like strings
and numbers.
and numbers.
>>> import transaction.tests.savepointsample
>>> import transaction.tests.savepointsample
>>> dm = transaction.tests.savepointsample.SampleSavepointDataManager()
>>> dm = transaction.tests.savepointsample.SampleSavepointDataManager()
>>> dm['name'] = 'bob'
>>> dm['name'] = 'bob'
...
@@ -44,13 +43,13 @@ and abort changes:
...
@@ -44,13 +43,13 @@ and abort changes:
>>> dm['name']
>>> dm['name']
'bob'
'bob'
Now, lets look at an application that manages funds for people.
Now, let
'
s look at an application that manages funds for people.
It allows deposits and debits to be entered for multiple people.
It allows deposits and debits to be entered for multiple people.
It accepts a sequence of entries and generates a sequence of status
It accepts a sequence of entries and generates a sequence of status
messages. For each entry, it applies the change and then validates
messages. For each entry, it applies the change and then validates
the user's account. If the user's account is invalid, we rol
e
back
the user's account. If the user's account is invalid, we rol
l
back
the change for that entry. The success or failure of an entry is
the change for that entry. The success or failure of an entry is
indicated in the output status. First we'll initialize some accounts:
indicated in the output status.
First we'll initialize some accounts:
>>> dm['bob-balance'] = 0.0
>>> dm['bob-balance'] = 0.0
>>> dm['bob-credit'] = 0.0
>>> dm['bob-credit'] = 0.0
...
@@ -65,8 +64,7 @@ Now, we'll define a validation function to validate an account:
...
@@ -65,8 +64,7 @@ Now, we'll define a validation function to validate an account:
... raise ValueError('Overdrawn', name)
... raise ValueError('Overdrawn', name)
And a function to apply entries. If the function fails in some
And a function to apply entries. If the function fails in some
unexpected way, it rolls back all of it's changes and
unexpected way, it rolls back all of its changes and prints the error:
prints the error:
>>> def apply_entries(entries):
>>> def apply_entries(entries):
... savepoint = transaction.savepoint()
... savepoint = transaction.savepoint()
...
@@ -108,7 +106,7 @@ Now let's try applying some entries:
...
@@ -108,7 +106,7 @@ Now let's try applying some entries:
>>> dm['sally-balance']
>>> dm['sally-balance']
-80.0
-80.0
If we
give
provide entries that cause an unexpected error:
If we provide entries that cause an unexpected error:
>>> apply_entries([
>>> apply_entries([
... ('bob', 10.0),
... ('bob', 10.0),
...
@@ -160,7 +158,7 @@ Once a savepoint has been used, it can't be used again:
...
@@ -160,7 +158,7 @@ Once a savepoint has been used, it can't be used again:
...
...
InvalidSavepointRollbackError
InvalidSavepointRollbackError
Using a savepoint also invalidates any savepoints that com
e
after it:
Using a savepoint also invalidates any savepoints that com
e
after it:
>>> savepoint1 = transaction.savepoint()
>>> savepoint1 = transaction.savepoint()
>>> dm['bob-balance'] = 100.0
>>> dm['bob-balance'] = 100.0
...
@@ -202,8 +200,8 @@ support savepoints:
...
@@ -202,8 +200,8 @@ support savepoints:
However, a flag can be passed to the transaction savepoint method to
However, a flag can be passed to the transaction savepoint method to
indicate that databases without savepoint support should be tolerated
indicate that databases without savepoint support should be tolerated
until a savepoint is roled back. This allows transactions to proceed
until a savepoint is rol
l
ed back. This allows transactions to proceed
i
s
there are no reasons to roll back:
i
f
there are no reasons to roll back:
>>> dm_no_sp['name'] = 'sally'
>>> dm_no_sp['name'] = 'sally'
>>> savepoint = transaction.savepoint(1)
>>> savepoint = transaction.savepoint(1)
...
@@ -228,7 +226,7 @@ uncommitable. From that point on, most transaction operations,
...
@@ -228,7 +226,7 @@ uncommitable. From that point on, most transaction operations,
including commit, will fail until the transaction is aborted.
including commit, will fail until the transaction is aborted.
In the previous example, we got an error when we tried to rollback the
In the previous example, we got an error when we tried to rollback the
savepoint. If we try to commit the transaction, the commit will fail:
savepoint.
If we try to commit the transaction, the commit will fail:
>>> transaction.commit() # doctest: +ELLIPSIS
>>> transaction.commit() # doctest: +ELLIPSIS
Traceback (most recent call last):
Traceback (most recent call last):
...
...
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