equal
deleted
inserted
replaced
48 nsid = ':%s.%s' % (config['pyro-ns-group'], database) |
48 nsid = ':%s.%s' % (config['pyro-ns-group'], database) |
49 locator = naming.NameServerLocator() |
49 locator = naming.NameServerLocator() |
50 # resolve the Pyro object |
50 # resolve the Pyro object |
51 try: |
51 try: |
52 nshost, nsport = config['pyro-ns-host'], config['pyro-ns-port'] |
52 nshost, nsport = config['pyro-ns-host'], config['pyro-ns-port'] |
53 uri = locator.getNS(nshost, nsport) .resolve(nsid) |
53 uri = locator.getNS(nshost, nsport).resolve(nsid) |
54 except ProtocolError: |
54 except ProtocolError: |
55 raise ConnectionError('Could not connect to the Pyro name server ' |
55 raise ConnectionError('Could not connect to the Pyro name server ' |
56 '(host: %s:%i)' % (nshost, nsport)) |
56 '(host: %s:%i)' % (nshost, nsport)) |
57 except NamingError: |
57 except NamingError: |
58 raise ConnectionError('Could not get repository for %s ' |
58 raise ConnectionError('Could not get repository for %s ' |
323 self.cursor_class = Cursor |
323 self.cursor_class = Cursor |
324 self.anonymous_connection = False |
324 self.anonymous_connection = False |
325 self.vreg = None |
325 self.vreg = None |
326 # session's data |
326 # session's data |
327 self.data = {} |
327 self.data = {} |
|
328 # XXX < 3.2 bw compat |
|
329 if 'EUser' in self._repo.get_schema(): |
|
330 self._user_etype = 'EUser' |
|
331 else: |
|
332 self._user_etype = 'CWUser' |
328 |
333 |
329 def __repr__(self): |
334 def __repr__(self): |
330 if self.anonymous_connection: |
335 if self.anonymous_connection: |
331 return '<Connection %s (anonymous)>' % self.sessionid |
336 return '<Connection %s (anonymous)>' % self.sessionid |
332 return '<Connection %s>' % self.sessionid |
337 return '<Connection %s>' % self.sessionid |
428 """return the User object associated to this connection""" |
433 """return the User object associated to this connection""" |
429 # cnx validity is checked by the call to .user_info |
434 # cnx validity is checked by the call to .user_info |
430 eid, login, groups, properties = self._repo.user_info(self.sessionid, props) |
435 eid, login, groups, properties = self._repo.user_info(self.sessionid, props) |
431 if req is None: |
436 if req is None: |
432 req = self.request() |
437 req = self.request() |
433 rset = req.eid_rset(eid, 'CWUser') |
438 rset = req.eid_rset(eid, self._user_etype) |
434 user = self.vreg.etype_class('CWUser')(req, rset, row=0, groups=groups, |
439 user = self.vreg.etype_class(self._user_etype)(req, rset, row=0, groups=groups, |
435 properties=properties) |
440 properties=properties) |
436 user['login'] = login # cache login |
441 user['login'] = login # cache login |
437 return user |
442 return user |
438 |
443 |
439 def __del__(self): |
444 def __del__(self): |
440 """close the remote connection if necessary""" |
445 """close the remote connection if necessary""" |