Search code examples
pythonpython-3.xcherrypyvirtualhost

Cherrypy 3.2 virtual host - application configuration


I am trying to use cherrypy virtualhost dispatcher for serving multiple different applications. My idea was to have separate configuration file for each application, but I am kinda lost. If I use virtualhost dispatcher, all applications are in same namespace, so for example section for database connection can occur only once. Or not? Can you please help?


Solution

  • For my current purposes, I am satisfied with this solution:

    I create separate config file for a cherrypy application and I am using the same class as cherrypy for parsing the file.

    from cherrypy.lib.reprconf import Config settings = Config(os.path.join(confPath, "settings.cfg"))

    Also, there is python standard module for handling config files named configparser.

    This question is also quite irrelevant for me, because serving multiple cherrypy applications (as I thought about it) is quite difficult with cherrypy server. I decided to use cherrypy as WSGI server behind appache and this solves the problem explicitly.