give the initial global_conf to loadcontext to initialize the context properly.

This commit is contained in:
Moriyoshi Koizumi 2013-05-31 17:31:36 +09:00 committed by benoitc
parent 3fcd1b969c
commit f5847a2a52

View File

@ -21,9 +21,10 @@ from gunicorn import util
class PasterBaseApplication(Application):
gcfg = None
def app_config(self):
cx = loadwsgi.loadcontext(SERVER, self.cfgurl, relative_to=self.relpath)
cx = loadwsgi.loadcontext(SERVER, self.cfgurl, relative_to=self.relpath, global_conf=self.gcfg)
gc, lc = cx.global_conf.copy(), cx.local_conf.copy()
cfg = {}
@ -85,13 +86,14 @@ class PasterApplication(PasterBaseApplication):
return self.app_config()
def load(self):
return loadapp(self.cfgurl, relative_to=self.relpath)
return loadapp(self.cfgurl, relative_to=self.relpath, global_conf=self.gcfg)
class PasterServerApplication(PasterBaseApplication):
def __init__(self, app, gcfg=None, host="127.0.0.1", port=None, *args, **kwargs):
self.cfg = Config()
self.gcfg = gcfg # need to hold this for app_config
self.app = app
self.callable = None
@ -138,7 +140,7 @@ class PasterServerApplication(PasterBaseApplication):
def load(self):
if hasattr(self, "cfgfname"):
return loadapp(self.cfgurl, relative_to=self.relpath)
return loadapp(self.cfgurl, relative_to=self.relpath, global_conf=self.gcfg)
return self.app