Cherrypy 3.2虚拟主机-应用程序配置
我正在尝试使用cherrypy虚拟主机调度程序来服务多个不同的应用程序。 我的想法是为每个应用程序都有单独的配置文件,但我有点迷失了。 如果我使用虚拟主机调度程序,所有应用程序都位于同一名称空间中,因此例如数据库连接部分只能出现一次。或不?你能帮忙吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
就我当前的目的而言,我对此解决方案感到满意:
我为cherrypy应用程序创建单独的配置文件,并且使用与cherrypy相同的类来解析文件。
从cherrypy.lib.reprconf导入配置
settings = Config(os.path.join(confPath, "settings.cfg"))
另外,还有一个 python 标准模块用于处理名为 配置解析器。
这个问题对我来说也无关紧要,因为用cherrypy服务器提供多个cherrypy应用程序(正如我所想的)是相当困难的。我决定使用cherrypy作为appache后面的WSGI服务器,这明确地解决了问题。
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.