I'm developing a new
site under Zope to replace our old one. This development came with a complete
restructuring of things, including folder structure and file names. I thought it
would be great to have a smart redirector that would redirect requests for the
old (currently non-existing) URLs to the corresponding new
URLs.
I however did want
to avoid writing hundreds of pages (DTMLs) just for containing the well-known
REQUEST.RESPONSE.redirect('/newfoo') expr.
Instead, I've made a
small Python script to do the job by defining a list of tuples for the possible
bad requests in which each element contain two items, the old URL (URI) and the
corresponding new. To say so, I've made a mapping from old directories to new
directories in the following manner:
Assume that you had
a folder named "/foo/bob" and the HTML files "/foo/foo.html",
"/foo/foo2.html" and "/foo/bob/bob.html". The new site, however, contains
the folder "/newfoo" as the corresponding for "foo" and "/newbob" for the old
"/foo/bob/". The corresponding docu for "/foo/foo.html" is
"/newfoo/newfoo_html", while "/foo/foo2.html" does not have such a corresponding
page and the index_html of "/newfoo" should be displayed.
In this case you
should make a mapping like:
mappings = [
('/foo/bob', '/newbob'),
('/foo/foo.html', '/newfoo/newfoo_html'),
('/foo', '/newfoo')
]
Iterating over the
list and matching the actual REQUEST's URL to the first item of each tuple, the
right URLs are constructed. Then the client has to be redirected to the new URL.
Let's call
the script doing the whole job "redirector"
Then I changed my
standard_error_message so that it first invokes the redirector script in
case of NotFound errors with the <dtml-call> tag.
What my problem is:
the redirector script cannot be called, although it is in the same folder as
standard_error_message, because Zope encounters a 404 error and displays its own
standard error message.
Does any good fellow
have any idea on how to call that script without having Zope so
crazy?
Thanks in
advance,
e-Musty