From 60f978e77cd7ae996d17aee0ba5be2dfc467a01e Mon Sep 17 00:00:00 2001 From: Philipp von Weitershausen Date: Thu, 29 Mar 2007 22:56:25 +0000 Subject: [PATCH] Treat relative filenames as relative to the PasteDeploy config file --- zope/paste/factory.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/zope/paste/factory.py b/zope/paste/factory.py index 1cec1c5..0f2d9a9 100644 --- a/zope/paste/factory.py +++ b/zope/paste/factory.py @@ -7,11 +7,18 @@ def zope_app_factory(global_conf, site_definition, file_storage=None, db_definition=None, devmode='no'): + # 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(site_definition, features) + zope.app.appsetup.config(abspath(site_definition), features) if file_storage is None and db_definition is None: raise TypeError("You must either provide a 'file_storage' or a " @@ -23,11 +30,12 @@ def zope_app_factory(global_conf, site_definition, file_storage=None, # open database if file_storage is not None: - db = zope.app.appsetup.database(file_storage) + db = zope.app.appsetup.database(abspath(file_storage)) else: schema_xml = os.path.join(os.path.dirname(__file__), 'schema.xml') schema = ZConfig.loadSchema(schema_xml) - cfgroot, cfghandlers = ZConfig.loadConfig(schema, db_definition) + cfgroot, cfghandlers = ZConfig.loadConfig( + schema, abspath(db_definition)) result, databases = multi_database(cfgroot.databases) db = result[0]