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