Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZEO
Commits
5bd99d83
Commit
5bd99d83
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
c117040f
Changes
1
Show 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 @
5bd99d83
import
sys
,
time
,
os
,
random
import
sys
,
time
,
os
,
random
import
transaction
from
persistent
import
Persistent
from
ZEO
import
ClientStorage
from
ZEO
import
ClientStorage
import
ZODB
import
ZODB
from
ZODB.POSException
import
ConflictError
from
ZODB.POSException
import
ConflictError
from
Persistence
import
Persistent
from
BTrees
import
OOBTree
import
BTree
class
ChatSession
(
Persistent
):
class
ChatSession
(
Persistent
):
...
@@ -28,7 +30,7 @@ class ChatSession(Persistent):
...
@@ -28,7 +30,7 @@ class ChatSession(Persistent):
self
.
name
=
name
self
.
name
=
name
# Internal attribute: _messages holds all the chat messages.
# Internal attribute: _messages holds all the chat messages.
self
.
_messages
=
BTree
.
BTree
()
self
.
_messages
=
OOBTree
.
OO
BTree
()
def
new_messages
(
self
):
def
new_messages
(
self
):
...
@@ -58,7 +60,7 @@ class ChatSession(Persistent):
...
@@ -58,7 +60,7 @@ class ChatSession(Persistent):
try
:
try
:
now
=
time
.
time
()
now
=
time
.
time
()
self
.
_messages
[
now
]
=
message
self
.
_messages
[
now
]
=
message
get_transaction
()
.
commit
()
transaction
.
commit
()
except
ConflictError
:
except
ConflictError
:
# Conflict occurred; this process should pause and
# Conflict occurred; this process should pause and
# wait for a little bit, then try again.
# wait for a little bit, then try again.
...
@@ -80,8 +82,8 @@ def get_chat_session(conn, channelname):
...
@@ -80,8 +82,8 @@ def get_chat_session(conn, channelname):
root
=
conn
.
root
()
root
=
conn
.
root
()
if
not
root
.
has_key
(
'chat_sessions'
):
if
not
root
.
has_key
(
'chat_sessions'
):
print
'Creating chat_sessions B-tree'
print
'Creating chat_sessions B-tree'
root
[
'chat_sessions'
]
=
BTree
.
BTree
()
root
[
'chat_sessions'
]
=
OOBTree
.
OO
BTree
()
get_transaction
()
.
commit
()
transaction
.
commit
()
sessions
=
root
[
'chat_sessions'
]
sessions
=
root
[
'chat_sessions'
]
...
@@ -90,7 +92,7 @@ def get_chat_session(conn, channelname):
...
@@ -90,7 +92,7 @@ def get_chat_session(conn, channelname):
if
not
sessions
.
has_key
(
channelname
):
if
not
sessions
.
has_key
(
channelname
):
print
'Creating new session:'
,
channelname
print
'Creating new session:'
,
channelname
sessions
[
channelname
]
=
ChatSession
(
channelname
)
sessions
[
channelname
]
=
ChatSession
(
channelname
)
get_transaction
()
.
commit
()
transaction
.
commit
()
session
=
sessions
[
channelname
]
session
=
sessions
[
channelname
]
return
session
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