Nevow with CGI - Using URLs in xml templates
I am using [1] Nevow in CGI environment Both relative and absolute URLs cannnot be used in xml templates. Consider the following apache setup. http://server/blog is rewritten (mod_rewrite) to http://server/cgi-bin/blog/index.py Now if an xml template contains this line <link rel="stylesheet" href="styles/screen.css" type="text/css" /> without rewrite the URL the browser will see is http://server/cgi-bin/blog/styles/screen.css and with rewritten the browser will see http://server/blog/styles/screen.css This depends on the current page, so sometimes the browser will see http://server/blog/2004/04/styles/screen.css (as the URL is relative). To cope with this problem with url.URL generation, I remember the parent-root URL in ctx. But I feel this is difficult to do with xml-templates as they are controlled by the user. Is there anyway to do translation in nevow? [1] http://srid.bsdnerds.org/blog/2005/02/06/nevow-with-cgi-and-wsgi-adaptor/ -- Sridhar Ratna - http://srid.bsdnerds.org
Il giorno dom, 13-02-2005 alle 17:21 +0530, Sridhar Ratna aka Srid ha scritto:
I am using [1] Nevow in CGI environment
Both relative and absolute URLs cannnot be used in xml templates. Consider the following apache setup.
http://server/blog is rewritten (mod_rewrite) to http://server/cgi-bin/blog/index.py
For files that have absolute positions, use absolute URLS and a VirtualHostMonster (import vhost ...). federico
On Sun, 13 Feb 2005 13:13:51 +0100, Federico Di Gregorio <fog@initd.org> wrote:
For files that have absolute positions, use absolute URLS and a VirtualHostMonster (import vhost ...).
Btw, for simplicity, I simply 'remember'ed the prefix URL in context. prefix_url_from_config = http://server/cgi-bin/blog/index.py ctx.remember(prefix_url_from_config, IRootURL) print url.URL.fromString(IRootURL(ctx)).child('foo').child('bar') http://server/cgi-bin/blog/index.py/foo/bar That's it. -- Sridhar Ratna - http://srid.bsdnerds.org
Sridhar Ratna aka Srid wrote:
Btw, for simplicity, I simply 'remember'ed the prefix URL in context.
prefix_url_from_config = http://server/cgi-bin/blog/index.py ctx.remember(prefix_url_from_config, IRootURL)
print url.URL.fromString(IRootURL(ctx)).child('foo').child('bar') http://server/cgi-bin/blog/index.py/foo/bar
That's it.
IMHO: Full URLs in configuration are Considered Harmful. They prevent a lot of useful things like providing the same service over HTTP and HTTPS.
On Mon, 14 Feb 2005 14:42:02 +0200, Tommi Virtanen <tv@twistedmatrix.com> wrote:
IMHO: Full URLs in configuration are Considered Harmful.
They prevent a lot of useful things like providing the same service over HTTP and HTTPS.
Anyways, I have switched to twisted/filesystemdb (from cgi/sqlite) for my blog application. ;-) -- Sridhar Ratna - http://srid.bsdnerds.org
participants (3)
-
Federico Di Gregorio
-
Sridhar Ratna aka Srid
-
Tommi Virtanen