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
99aa5fa4
Commit
99aa5fa4
authored
Nov 26, 2009
by
Laurence Rowe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add download link to chatter.py; add transaction abort to conflict handling
parent
c70f34f6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
9 deletions
+8
-9
zodbguide/chatter.py
zodbguide/chatter.py
+2
-2
zodbguide/zeo.rst
zodbguide/zeo.rst
+6
-7
No files found.
zodbguide/chatter.py
View file @
99aa5fa4
...
...
@@ -62,10 +62,10 @@ class ChatSession(Persistent):
self
.
_messages
[
now
]
=
message
transaction
.
commit
()
except
ConflictError
:
# Conflict occurred; this process should
pause and
# Conflict occurred; this process should
abort,
# wait for a little bit, then try again.
transaction
.
abort
()
time
.
sleep
(.
2
)
pass
else
:
# No ConflictError exception raised, so break
# out of the enclosing while loop.
...
...
zodbguide/zeo.rst
View file @
99aa5fa4
...
...
@@ -155,11 +155,10 @@ Sample Application: chatter.py
For an example application, we'll build a little chat application. What's
interesting is that none of the application's code deals with network
programming at all; instead, an object will hold chat messages, and be magically
shared between all the clients through ZEO. I won't present the complete script
here; it's included in my ZODB distribution, and you can download it from
`<http://www.amk.ca/zodb/demos/>`_. Only the interesting portions of the code
will be covered here.
programming at all; instead, an object will hold chat messages, and be
magically shared between all the clients through ZEO. I won't present the
complete script here; you can download it from :download:`chatter.py
<chatter.py>`. Only the interesting portions of the code will be covered here.
The basic data structure is the :class:`ChatSession` object, which provides an
:meth:`add_message` method that adds a message, and a :meth:`new_messages`
...
...
@@ -197,10 +196,10 @@ breaking out of the loop when the commit works without raising an exception. ::
self._messages[now] = message
get_transaction().commit()
except ConflictError:
# Conflict occurred; this process should
pause and
# Conflict occurred; this process should
abort,
# wait for a little bit, then try again.
transaction.abort()
time.sleep(.2)
pass
else:
# No ConflictError exception raised, so break
# out of the enclosing while loop.
...
...
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