[Moin-user] Creating a dynamic header like http://moinmoin.wikiwikiweb.de/

Steve Lianoglou mailinglist.honeypot at gmail.com
Mon Sep 22 19:09:27 EDT 2008

Steve Lianoglou <mailinglist.honeypot <at> gmail.com> writes:


> This is all fine so far, but I'm curious if/how I can make the URL that I 
> report
> in my `page_header1` to be dynamic, like it is on the moinmoin.wikiweb.de
> site
> so that it can return the appropriate URL for the same page on the new
> server
> that the user is trying to access on the old server.
> So, in the header, when the user tries to access this page:
> http://example.com/cgi-bin/moin.cgi/SomePage
> I'd like to convert it to:
> http://new.example.com/SomePage
> (we moved from cgi to mod_wsgi, to boot)

Replying to myself, and for posterity ...

When run as a CGI, the os.environ['REQUEST_URI'] has the
"/cgi-bin/moin.cgi/SomePage" part of the request.

You can grab that string, mangle it however you like, and use it in the
page_header/footer. So in the specific case I outlined above, I can do 
something like this:

    import os
    _new_url = 'http://new.example.com/%s' % os.environ['REQUEST_URI'][18:]
    page_header1 = '<p>The new URL for this page is: ' \
                   '<a href="%s">%s</a></p>' % (_new_url, _new_url)

And the new address will be listed at the top of every page ... 
style w/ custom message and css to taste.


More information about the Moin-user mailing list