[Zodb-checkins] CVS: ZODB/doc/guide - chatter.py:1.4

Jeremy Hylton jeremy at zope.com
Fri Apr 16 15:10:53 EDT 2004


Update of /cvs-repository/ZODB/doc/guide
In directory cvs.zope.org:/tmp/cvs-serv17693/doc/guide

Modified Files:
	chatter.py 
Log Message:
Update to use transaction and BTrees packages.


=== ZODB/doc/guide/chatter.py 1.3 => 1.4 ===
--- ZODB/doc/guide/chatter.py:1.3	Thu Oct  2 14:17:29 2003
+++ ZODB/doc/guide/chatter.py	Fri Apr 16 15:10:52 2004
@@ -1,11 +1,13 @@
 
 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 @@
         self.name = name
 
         # Internal attribute: _messages holds all the chat messages.
-        self._messages = BTree.BTree()
+        self._messages = OOBTree.OOBTree()
 
 
     def new_messages(self):
@@ -58,7 +60,7 @@
             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 @@
     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.OOBTree()
+        transaction.commit()
 
     sessions = root['chat_sessions']
 
@@ -90,7 +92,7 @@
     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




More information about the Zodb-checkins mailing list