load site_cubicweb as a module instead of execing it, avoid reimport pbs stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 15 Dec 2009 11:30:44 +0100
branchstable
changeset 4120 21517d42f2ed
parent 4119 85bb30fb6d9b
child 4121 09622a18501c
child 4126 2eb47c1efee1
load site_cubicweb as a module instead of execing it, avoid reimport pbs
cwconfig.py
--- a/cwconfig.py	Mon Dec 14 17:54:45 2009 +0100
+++ b/cwconfig.py	Tue Dec 15 11:30:44 2009 +0100
@@ -865,12 +865,12 @@
                     self.warning('site_erudi.py is deprecated, should be renamed to site_cubicweb.py')
 
     def _load_site_cubicweb(self, sitefile):
-        context = {'__file__': sitefile}
-        execfile(sitefile, context, context)
+        from logilab.common.modutils import load_module_from_file
+        module = load_module_from_file(sitefile)
         self.info('%s loaded', sitefile)
         # cube specific options
-        if context.get('options'):
-            self.register_options(context['options'])
+        if getattr(module, 'options', None):
+            self.register_options(module.options)
             self.load_defaults()
 
     def load_configuration(self):