Skip to content

Commit

Permalink
Treat relative filenames as relative to the PasteDeploy config file
Browse files Browse the repository at this point in the history
  • Loading branch information
philikon committed Mar 29, 2007
1 parent f848a9b commit 60f978e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions zope/paste/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand All @@ -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]
Expand Down

0 comments on commit 60f978e

Please sign in to comment.