1
2
3
4
5
6
7
8
9
10
11
12
13
14
16
17 - def __init__(self, host="localhost", port=8100):
18 from ZEO import ClientStorage
19 from ZODB import DB
20 addr = (host, port)
21 storage=ClientStorage.ClientStorage(addr)
22 self.db=DB(storage)
23 self.app = None
24 self.dmd = None
25 self.opendb()
26
27
29 if self.app: return
30 self.connection=self.db.open()
31 root=self.connection.root()
32 self.app=root['Application']
33 self._getContext(self.app)
34 self.dmd = self.app.zport.dmd
35
36
38 self.connection.sync()
39
40
46
47
48 - def _getContext(self, app):
49 from ZPublisher.HTTPRequest import HTTPRequest
50 from ZPublisher.HTTPResponse import HTTPResponse
51 from ZPublisher.BaseRequest import RequestContainer
52 resp = HTTPResponse(stdout=None)
53 env = {
54 'SERVER_NAME':'localhost',
55 'SERVER_PORT':'8080',
56 'REQUEST_METHOD':'GET'
57 }
58 req = HTTPRequest(None, env, resp)
59 return app.__of__(RequestContainer(REQUEST = req))
60