These are chat archives for cherrypy/cherrypy

Aug 2018
Aug 21 2018 11:29
Hi, is there any possibility to read the application configs from a file when using RoutesDispatcher instead of MethodDispatcher. Something similar as explained in this question ->
Sviatoslav Sydorenko
Aug 21 2018 11:34
the question is too broad to understand what you want
create your own on SO with full description and listing what you've tried
Sviatoslav Sydorenko
Aug 21 2018 12:39
could you please use tripple backticks? ```
Also, a public post on StackOverflow is better, since it'll be better googlable for other seekers
Aug 21 2018 12:40

Here, is my current code

from controller import ReqController

req_dispatcher = cherrypy.dispatch.RoutesDispatcher()

    action='req_handle', controller=ReqController())

conf = {
    '/': {
        'request.dispatch': req_dispatcher,
        'log.error_file': 'app.log',
        'log.access_file': 'access.log',
        'log.screen': False

cherrypy.tree.mount(root=None, config=conf)

My question is this, how can I move the contents of conf from a python dict to a file. In the docs, there are only examples given for MethodDispatcher() class.
I have tried creating a file containing the contents of the conf dict, but I got the following error:

ValueError: ("Config error in section: '/', option: 'request.dispatch', value: 'req_dispatcher'. Config values must be valid Python.", 'TypeError', ("unrepr could not resolve the name 'req_dispatcher'",))
Sviatoslav Sydorenko
Aug 21 2018 12:41
what exactly have you tried?
also, reprparser needs to know in which module this name exists
anyway, create SO question, so the answer could go there
Aug 21 2018 12:43
I'll create it and post the link
Sviatoslav Sydorenko
Aug 21 2018 16:51