1
2
3
4
5
6
7
8
9
10
11
12
13
14 from Products.ZenUtils.Utils import set_context
15
17
18 - def __init__(self, host="localhost", port=8100):
19 from ZEO import ClientStorage
20 from ZODB import DB
21 addr = (host, port)
22 storage=ClientStorage.ClientStorage(addr)
23 self.db=DB(storage)
24 self.app = None
25 self.dmd = None
26 self.opendb()
27
28
30 if self.app: return
31 self.connection=self.db.open()
32 root=self.connection.root()
33 app = root['Application']
34 self.app = set_context(app)
35 self.dmd = self.app.zport.dmd
36
37
39 self.connection.sync()
40
41
43 self.connection.close()
44 self.db.close()
45 self.app = None
46 self.dmd = None
47