[parser host mapping] take care to cases where apphome is None (c-c i18ncube command for instance)
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 10 Feb 2011 12:28:31 +0100
changeset 6970 a6ccbfbacf3d
parent 6969 c527de85ea61
child 6971 33afb8748052
[parser host mapping] take care to cases where apphome is None (c-c i18ncube command for instance)
sobjects/parsers.py
--- a/sobjects/parsers.py	Wed Feb 09 19:00:25 2011 +0100
+++ b/sobjects/parsers.py	Thu Feb 10 12:28:31 2011 +0100
@@ -341,11 +341,11 @@
         self._cw.execute(rql, {'x': entity.eid})
 
 def registration_callback(vreg):
+    vreg.register_all(globals().values(), __name__)
     global HOST_MAPPING
-    vreg.register_all(globals().values(), __name__)
-    host_mapping_file = osp.join(vreg.config.apphome, 'hostmapping.py')
-    if osp.exists(host_mapping_file):
-        HOST_MAPPING = eval(file(host_mapping_file).read())
-        vreg.info('using host mapping %s from %s', HOST_MAPPING, host_mapping_file)
-    else:
-        HOST_MAPPING = {}
+    HOST_MAPPING = {}
+    if vreg.config.apphome:
+        host_mapping_file = osp.join(vreg.config.apphome, 'hostmapping.py')
+        if osp.exists(host_mapping_file):
+            HOST_MAPPING = eval(file(host_mapping_file).read())
+            vreg.info('using host mapping %s from %s', HOST_MAPPING, host_mapping_file)