Issue #1262 new

Cannot set request.app.relative_urls from config file

yajo
created an issue

I set in my config file this, among other things:

[/]
request.app.relative_urls: 'server'

Then, I run my app, but cherrypy.url creates absolute paths, including the server name.

Debugging it, I get this weird behavior:

>>> getattr(cherrypy.request.app, 'relative_urls')
False
>>> getattr(cherrypy.request, 'app.relative_urls')
'server'
>>> cherrypy.request.app.config
{
# Other stuff...
'/' :   {'request.app.relative_urls' : 'server'}
}
>>> cherrypy.__version__
'3.2.4'

Seems like what the config parsing does is that it attaches an "app.relative_urls" property in cherrypy.request instead of setting the value of cherrypy.request.app.relative_urls.

Comments (4)

  1. Robert Brewer

    Since request.app refers to an Application object that is shared between requests, it doesn't make sense (and can cause strange problems) to set config on it per request. If you'd like request.app.relative_urls to be set for all URI's, you should probably do so in code, not config (before you call engine.start).

    If there's a case for making this setting configurable per URI, then we'd need to add a request.relative_urls attribute (in a future version).

  2. Log in to comment