Python日志记录模块和CherryPy 的 Config API都使用ConfigParser文件。因此,我假设我可以为我自己的应用程序配置使用一个配置文件,它是日志记录配置和 CherryPy 的配置。
当我的日志记录和 CherryPy 分开时,它们运行良好,并且我的配置文件使用 ConfigParser api 解析时没有错误。然而,CherryPy 似乎在这部分吐槽:
[loggers]
keys=root,myapp,cherrypy,cperror,cpaccess
给出以下例外:
Traceback (most recent call last):
File "/usr/lib/python2.6/multiprocessing/process.py", line 232, in _bootstrap
self.run()
File "/usr/lib/python2.6/multiprocessing/process.py", line 88, in run
self._target(*self._args, **self._kwargs)
File "unittests.py", line 431, in main
cherrypy.config.update(server.CONFIG_FILE)
File "/usr/lib/pymodules/python2.6/cherrypy/_cpconfig.py", line 263, in update
config = _Parser().dict_from_file(config)
File "/usr/lib/pymodules/python2.6/cherrypy/_cpconfig.py", line 383, in dict_from_file
return self.as_dict()
File "/usr/lib/pymodules/python2.6/cherrypy/_cpconfig.py", line 374, in as_dict
raise ValueError(msg, x.__class__.__name__, x.args)
ValueError: ("Config error in section: 'loggers', option: 'keys', value: 'root,myapp,cherrypy,cperror,cpaccess'. Config values must be valid Python.", 'TypeError', ("unrepr could not resolve the name 'root'",))
CherryPy 文档从未说过 CherryPy 需要将其配置文件与您的其他配置分开,但我开始认为这可能是必要的。文档说,如果每个站点有多个应用程序,则站点和应用程序配置可能需要分开,但这似乎是一个不同的问题……是否将我的日志记录配置误认为 CherryPy 应用程序配置?
这可能吗?如果不是,那么我不确定为什么 CherryPy 甚至会首先使用 ConfigParser 库。