在cherrypy配置文件中的常量

时间:2012-04-04 10:40:12

标签: python configuration constants cherrypy

我有以下Cherrypy配置文件:

[/tmp]
tools.staticdir.on: True
tools.staticdir.dir: "../something/path/"

是否可以将字符串"../something/path/“作为常量放在此文件中并使用类似的内容:tools.staticdir.dir:MY_PATH_CONST?如果可行,该怎么做?

1 个答案:

答案 0 :(得分:0)

在配置文件中添加标识符...

[custompath]
path : "../something/path/"
然后

以这种方式访问​​代码中的路径:

cherrypy.request.app.config['custompath']['path']

希望这有帮助。

安德鲁

相关问题