Commits

Miki Tebeka  committed d210bb8

Better load_config

  • Participants
  • Parent commits 2a56206

Comments (0)

Files changed (1)

File pycfg/config.py

 # If this file is in PYTHONPATH, then 'import config'
 # Otherwise, something like the following should work (Python 2x)
 #
+#    from os.path import dirname
+#    import sys
+#    import imp
+#
 #    def load_config(path):
-#        class _cfg: pass
-#        cfg = _cfg()
-#        cfg.__file__ = path
-#
-#        execfile(path, {}, cfg.__dict__)
-#        return cfg
+#        imp.acquire_lock()
+#        try:
+#            sys.path.insert(0, dirname(path))
+#            return imp.load_source('cfg', path)
+#        finally:
+#            sys.path.pop(0)
+#            imp.release_lock()
+
 
 # Overrideable configuration, keep it flat
 web_host = 'localhost'