Cherrypy:从cherryd开始时获取应用程序配置设置

时间:2013-01-14 20:17:27

标签: python cherrypy

我使用以下命令启动脚本:

cherryd -c tiny.cfg -i tiny

但我无法阅读应用配置设置(数据库)。有什么问题?

tiny.py

import cherrypy

class HelloWorld:
    def index(self):
        return "Hello world!"
    index.exposed = True

app = cherrypy.tree.mount(HelloWorld(), '/')
print 'app.config', app.config
print 'cherrypy.config', cherrypy.config

tiny.cfg

[global]
server.socket_host: "0.0.0.0"

[database]
driver: "mysql"
host: "localhost"

1 个答案:

答案 0 :(得分:1)

尝试将配置传递给tree.mount调用:

app = cherrypy.tree.mount(HelloWorld(), '/', 'tiny.cfg')