Samus CTO (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-server/trunk-environment-vars-2-cto into 
lp:openobject-server.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-environment-vars-2-cto/+merge/98830

Add env vars capability + addons_path can be split using ':' separator 
(Unix-like path separator)
-- 
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-environment-vars-2-cto/+merge/98830
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-server/trunk-environment-vars-2-cto.
=== modified file 'openerp/tools/config.py'
--- openerp/tools/config.py	2012-03-02 11:28:34 +0000
+++ openerp/tools/config.py	2012-03-22 12:25:23 +0000
@@ -359,6 +359,16 @@
                 or os.environ.get('OPENERP_SERVER') or rcfilepath)
         self.load()
 
+        ## Enabled just for options, not 'misc'
+        for option in self.options:
+            try:
+                self.options[option] = os.environ["OPENERP_%s" % option.upper()]
+                if option in ('admin_passwd',): raise RuntimeError
+            except RuntimeError:
+                sys.stderr.write("Passing security-related option `%s' via environment is forbidden\n" % option)
+                os._exit(1)
+            except KeyError:
+                continue
 
         # Verify that we want to log or not, if not the output will go to stdout
         if self.options['logfile'] in ('None', 'False'):
@@ -406,12 +416,6 @@
                 self.options[arg] = optparse.Option.TYPE_CHECKER[self.casts[arg].type](self.casts[arg], arg, self.options[arg])
 
         self.options['root_path'] = os.path.abspath(os.path.expanduser(os.path.expandvars(os.path.dirname(openerp.__file__))))
-        if not self.options['addons_path'] or self.options['addons_path']=='None':
-            self.options['addons_path'] = os.path.join(self.options['root_path'], 'addons')
-        else:
-            self.options['addons_path'] = ",".join(
-                    os.path.abspath(os.path.expanduser(os.path.expandvars(x)))
-                      for x in self.options['addons_path'].split(','))
 
         self.options['init'] = opt.init and dict.fromkeys(opt.init.split(','), 1) or {}
         self.options["demo"] = not opt.without_demo and self.options['init'] or {}
@@ -468,7 +472,25 @@
 
         openerp.conf.max_cron_threads = self.options['max_cron_threads']
 
-        openerp.conf.addons_paths = self.options['addons_path'].split(',')
+        # TODO =='None' is useless since apply of patch:
+        # lp:~openerp-dev/openobject-server/trunk-simplify-boolean-in-config-files-cto
+        if not self.options['addons_path'] or self.options['addons_path']=='None':
+            self.options['addons_path'] = os.path.join(self.options['root_path'], 'addons')
+
+        # Explode addons path, default way
+        if self.options['addons_path'].find(',') >= 0:
+            openerp.conf.addons_paths = self.options['addons_path'].split(',')
+
+        # Explode addons path, like Unix env vars
+        elif self.options['addons_path'].find(':') >= 0:
+            openerp.conf.addons_paths = self.options['addons_path'].split(':')
+
+        else: openerp.conf.addons_paths = [self.options['addons_path']]
+
+        # Expand addons to absolute path !AFTER self.save()
+        for i, path in enumerate(openerp.conf.addons_paths):
+            openerp.conf.addons_paths[i] = os.path.abspath(os.path.expanduser(os.path.expandvars(path)))
+
         if opt.server_wide_modules:
             openerp.conf.server_wide_modules = map(lambda m: m.strip(), opt.server_wide_modules.split(','))
         else:

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to