[pyro] instance id cleanup, ensure config['pyro-instance-id'] is a fully qualified pyro id on the server side
--- 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