[Checkins] SVN: zope.paste/trunk/zope/paste/factory.py Refactoring: replace the abspath() closure with os.path.abspath.

Marius Gedminas cvs-admin at zope.org
Mon Aug 20 15:02:15 UTC 2012


Log message for revision 127529:
  Refactoring: replace the abspath() closure with os.path.abspath.
  
  os.path.abspath(anything, absolute_path) returns absolute_path already,
  so the os.path.isabs() check is redundant.
  
  I want to refactor the DB setup bits into a separate utility function,
  and the use of this closure is in my way.

Changed:
  U   zope.paste/trunk/zope/paste/factory.py

-=-
Modified: zope.paste/trunk/zope/paste/factory.py
===================================================================
--- zope.paste/trunk/zope/paste/factory.py	2012-08-20 15:01:38 UTC (rev 127528)
+++ zope.paste/trunk/zope/paste/factory.py	2012-08-20 15:02:11 UTC (rev 127529)
@@ -28,18 +28,12 @@
     if _zope_app is not None:
         return _zope_app
 
-    # relative filenames are understood to be relative to the
-    # PasteDeploy configuration file
-    def abspath(path):
-        if os.path.isabs(path):
-            return path
-        return os.path.join(global_conf['here'], path)
-
     # load ZCML (usually site.zcml)
     features = ()
     if devmode.lower() in ('yes', 'true', 'on'):
         features += ('devmode',)
-    zope.app.appsetup.config(abspath(site_definition), features)
+    filename = os.path.join(global_conf['here'], site_definition)
+    zope.app.appsetup.config(filename, features)
 
     if file_storage is not None and db_definition is not None:
         raise TypeError("You may only provide a 'file_storage' or a "
@@ -47,12 +41,13 @@
 
     # open database
     if file_storage is not None:
-        db = zope.app.appsetup.database(abspath(file_storage))
+        filename = os.path.join(global_conf['here'], file_storage)
+        db = zope.app.appsetup.database(filename)
     elif db_definition is not None:
+        filename = os.path.join(global_conf['here'], db_definition)
         schema_xml = os.path.join(os.path.dirname(__file__), 'schema.xml')
         schema = ZConfig.loadSchema(schema_xml)
-        cfgroot, cfghandlers = ZConfig.loadConfig(
-            schema, abspath(db_definition))
+        cfgroot, cfghandlers = ZConfig.loadConfig(schema, filename)
 
         result, databases = multi_database(cfgroot.databases)
         db = result[0]



More information about the checkins mailing list