These are chat archives for cherrypy/cherrypy

7th
Jul 2018
Ader
@y1n0
Jul 07 2018 18:29
Hi, is there a way that I can access the configs when the app is being initialized? something probably like request.app.conf but while initializing time
Jason R. Coombs
@jaraco
Jul 07 2018 18:31
@y1n0: cherrypy.config maybe?
Ader
@y1n0
Jul 07 2018 18:35
@jaraco that only has the global entries I think. I could find a section I defined myself there.
oh wait, I can put my key=val in the global section, right
Jason R. Coombs
@jaraco
Jul 07 2018 18:40
Sure. And many cherrypy apps do.
Ader
@y1n0
Jul 07 2018 18:41
okay. thank you.
tho they are more app-specific info, but.. it works
Jason R. Coombs
@jaraco
Jul 07 2018 18:46
@y1n0: You can access the configs for a given path by referencing the path:
>>> cherrypy.config.update({'/foo': {'tools.auth_basic.on': True}})
>>> cherrypy.config['/foo']['tools.auth_basic.on']
True
(of course that only works if you set that config at initialization time)
If you’re relying on dispatch-time config, such as with _cp_config, those won’t be discoverable unless you traverse the tree yourself.
Ader
@y1n0
Jul 07 2018 19:15
no that does not work as I have the configs in an external file.
what I meant by app-specific is that they are related to app but they are not Application Config as defined in the doc and are applied to the app object
and still, I can access those too when the app obj is still being initialized (i,e in __init__)
I tried and found tree.app empty.
I think I will just put my special conf in [global].