I have a CherryPy-based webapp that needs to access CherryPy configuration files before a user makes a request. The docs say use:
host = cherrypy.request.app.config ['database'] ['host']
But this will not work outside of the user request. You can also use the application object when starting the application as follows:
...
application = cherrypy.tree.mount (root, '/', app_conf)
host = application.config ['database'] ['host']
...
But I do not see access to the "application" from other classes outside the user request.
I ask, because our application scans several databases, and we configure them when the application starts, and not at the request of the user. I have a feeling that it would be useful elsewhere; so is there a way to save the link to the โapplicationโ somewhere or access it through the CherryPy API?
source
share