Cherrypy can't find options when using apache?
I've been having a strange problem with cherrypy. When I quickstart an application:
cherrypy.quickstart(WebApps(), '/dev/apps/', 'settings.config')
Everything works fine. However, when I try to load my application through apache mod_wsgi, it seems that none of the default options from the options file are passed to the tool I created.
I basically have a simple tool:
@cherrypy.expose
@cherrypy.tools.checkStatus()
def doSomething(self,*args, **kwargs):
#process the page here
...
def checkStatus(**kwargs):
#handle stuff here
and a very simple settings.config file:
[global]
tools.checkStatus.redirect = 'http://localhost/dev/MyRedirectPage.html'
tools.checkStatus.returnAfterRedirect = True
As stated above, when I run from the quickstart function, checkstatus is passed a dictionary of parameters, containing 'redirect' and 'returnAfterRedirect'.
Whenever the app is launched from mod_wsgi, the code runs, but no paramters are passed to kwargs.
def application(environ, start_response):
app = cherrypy.tree.mount(WebApps(),
'/dev/apps/',
os.path.join(currentPath,'settings.config'))
return app(environ, start_response)
Am I missing 开发者_StackOverflow社区something obvious here? Why does the first version work and not the second?
Thanks
I'd start by verifying that os.path.join(currentPath,'settings.config')
is what you think it should be...
But assuming it is, then try moving your config entries from [global]
to [/]
. quickstart
will pass the same config to both cherrypy.config.update
(the global config) and app.config
(application-specific config), but tree.mount
only does the latter.
精彩评论