[pyro] instance id cleanup, ensure config['pyro-instance-id'] is a fully qualified pyro id on the server side stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 04 Aug 2010 10:22:11 +0200
branchstable
changeset 6061 7cb29eab1c9d
parent 6060 353bec342e2a
child 6062 f1a550102f5c
[pyro] instance id cleanup, ensure config['pyro-instance-id'] is a fully qualified pyro id on the server side
dbapi.py
server/repository.py
web/webconfig.py
--- a/dbapi.py	Tue Aug 03 14:43:20 2010 +0200
+++ b/dbapi.py	Wed Aug 04 10:22:11 2010 +0200
@@ -100,9 +100,9 @@
     else: # method == 'pyro'
         # resolve the Pyro object
         from logilab.common.pyro_ext import ns_get_proxy
+        pyroid = database or config['pyro-instance-id'] or config.appid
         try:
-            return ns_get_proxy(database,
-                                defaultnsgroup=config['pyro-ns-group'],
+            return ns_get_proxy(pyroid, defaultnsgroup=config['pyro-ns-group'],
                                 nshost=config['pyro-ns-host'])
         except Exception, ex:
             raise ConnectionError(str(ex))
--- a/server/repository.py	Tue Aug 03 14:43:20 2010 +0200
+++ b/server/repository.py	Wed Aug 04 10:22:11 2010 +0200
@@ -1216,15 +1216,17 @@
 
     def pyro_register(self, host=''):
         """register the repository as a pyro object"""
-        import tempfile
-        from logilab.common.pyro_ext import register_object, config
-        config.PYRO_STORAGE = tempfile.gettempdir() # XXX until lgc > 0.45.1 is out
-        appid = self.config['pyro-instance-id'] or self.config.appid
-        daemon = register_object(self, appid, self.config['pyro-ns-group'],
-                                 self.config['pyro-host'],
-                                 self.config['pyro-ns-host'])
-        msg = 'repository registered as a pyro object using group %s and id %s'
-        self.info(msg, self.config['pyro-ns-group'], appid)
+        from logilab.common import pyro_ext as pyro
+        config = self.config
+        appid = '%s.%s' % pyro.ns_group_and_id(
+            config['pyro-instance-id'] or config.appid,
+            config['pyro-ns-group'])
+        # ensure config['pyro-instance-id'] is a full qualified pyro name
+        config['pyro-instance-id'] = appid
+        daemon = pyro.register_object(self, appid,
+                                      daemonhost=config['pyro-host'],
+                                      nshost=config['pyro-ns-host'])
+        self.info('repository registered as a pyro object %s', appid)
         self.pyro_registered = True
         return daemon
 
--- a/web/webconfig.py	Tue Aug 03 14:43:20 2010 +0200
+++ b/web/webconfig.py	Wed Aug 04 10:22:11 2010 +0200
@@ -238,11 +238,7 @@
             return self.__repo
         except AttributeError:
             from cubicweb.dbapi import get_repository
-            if self.repo_method == 'inmemory':
-                repo = get_repository('inmemory', vreg=vreg, config=self)
-            else:
-                repo = get_repository('pyro', self['pyro-instance-id'],
-                                      config=self)
+            repo = get_repository(self.repo_method, vreg=vreg, config=self)
             self.__repo = repo
             return repo