CherryPy configuration tools.staticdir.root problem

Posted by Alan Harris-Reid on Stack Overflow See other posts from Stack Overflow or by Alan Harris-Reid
Published on 2010-06-02T01:00:58Z Indexed on 2010/06/02 1:03 UTC
Read the original article Hit count: 354

Hi there,

How can I make my static-file root directories relative to my application root folder (instead of a hard-coded path)?

In accordance with CP instructions (http://www.cherrypy.org/wiki/StaticContent) I have tried the following in my configuration file:

tree.cpapp = cherrypy.Application(cpapp.Root())
tools.staticdir.root = cpapp.current_dir

but when I run cherrpy.quickstart(rootclass, script_name='/', config=config_file) I get the following error

builtins.ValueError: ("Config error in section: 'global', option: 'tree.cpapp', value: 'cherrypy.Application(cpapp.Root())'. Config values must be valid Python.", 'TypeError', ("unrepr could not resolve the name 'cpapp'",))

I know I can do configuration from within the main.py file just before quickstart is called (eg. using os.path.abspath(os.path.dirname(file))), but I prefer using the idea of a separate configuration file if possible.

Any help would be appreciated (in case it is relevant, I am using CP 3.2 with Python 3.1)

TIA Alan

© Stack Overflow or respective owner

Related posts about python

Related posts about configuration