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
456b5d9c
Commit
456b5d9c
authored
Apr 16, 2004
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update to use transaction and BTrees packages.
parent
30944096
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
+9
-7
doc/guide/chatter.py
doc/guide/chatter.py
+9
-7
No files found.
doc/guide/chatter.py
View file @
456b5d9c
import
sys
,
time
,
os
,
random
import
transaction
from
persistent
import
Persistent
from
ZEO
import
ClientStorage
import
ZODB
from
ZODB.POSException
import
ConflictError
from
Persistence
import
Persistent
import
BTree
from
BTrees
import
OOBTree
class
ChatSession
(
Persistent
):
...
...
@@ -28,7 +30,7 @@ class ChatSession(Persistent):
self
.
name
=
name
# Internal attribute: _messages holds all the chat messages.
self
.
_messages
=
BTree
.
BTree
()
self
.
_messages
=
OOBTree
.
OO
BTree
()
def
new_messages
(
self
):
...
...
@@ -58,7 +60,7 @@ class ChatSession(Persistent):
try
:
now
=
time
.
time
()
self
.
_messages
[
now
]
=
message
get_transaction
()
.
commit
()
transaction
.
commit
()
except
ConflictError
:
# Conflict occurred; this process should pause and
# wait for a little bit, then try again.
...
...
@@ -80,8 +82,8 @@ def get_chat_session(conn, channelname):
root
=
conn
.
root
()
if
not
root
.
has_key
(
'chat_sessions'
):
print
'Creating chat_sessions B-tree'
root
[
'chat_sessions'
]
=
BTree
.
BTree
()
get_transaction
()
.
commit
()
root
[
'chat_sessions'
]
=
OOBTree
.
OO
BTree
()
transaction
.
commit
()
sessions
=
root
[
'chat_sessions'
]
...
...
@@ -90,7 +92,7 @@ def get_chat_session(conn, channelname):
if
not
sessions
.
has_key
(
channelname
):
print
'Creating new session:'
,
channelname
sessions
[
channelname
]
=
ChatSession
(
channelname
)
get_transaction
()
.
commit
()
transaction
.
commit
()
session
=
sessions
[
channelname
]
return
session
...
...
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