1
2
3
4
5
6
7
8
9
10
11 from threading import Thread
12
14 """
15 Thread running inside zope that has its own read-only connection to the db.
16 """
17
19 Thread.__init__(self)
20 self.setDaemon(1)
21
22
24 """Open a connection to the zope database.
25 """
26 from Zope2 import DB
27 self.conn = DB.open()
28 root = self.conn.root()
29 self.app = root['Application']
30
31
33 """Sync the connection to the zope database.
34 """
35 self.conn.sync()
36
37
39 """Abort our transaction (we are read-only) and close connection.
40 """
41 try:
42 import transaction
43 transaction.abort()
44 self.conn.close()
45 except:
46 pass
47