[Zope] Smart redirecting? Help me in a script call in standard_error_message

Jens Vagelpohl jens@zope.com
Mon, 28 Jan 2002 21:42:51 -0500


if you get the "built-in" error page even though you call your own =
script=20
it is likely that executing your script produces errors. in that case =
zope=20
will fall back to the filesystem code to display the error message.

i made a product just a couple weeks ago for the exact purpose you =
describe.
  you can use it to handle redirects transparently or you can call it so =
it=20
gives you the redirect URL and do the redirect manually. it keeps logs =
of=20
requests that go through it (with a management interface to display =
simple=20
stats about the log) and has an easy management interface to define new=20=

"old url: new url"-mappings with selectable HTTP response status codes.

the product is at http://www.dataflake.org/software/jredirector . i'm =
using=20
it successfully on my own sites.

jens


On Monday, January 28, 2002, at 08:37 , e-Musty wrote:

> I'm developing a new site under Zope to replace our old one. This=20
> development came with a complete restructuring of things, including =
folder=20
> structure and file names. I thought it would be great to have a smart=20=

> redirector that would redirect requests for the old (currently=20
> non-existing) URLs to the corresponding new URLs.
> =A0
> I however did want to avoid writing hundreds of pages (DTMLs) just for=20=

> 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=20
> of tuples for the possible bad requests in which each element contain =
two=20
> items, the old URL (URI) and the corresponding new. To say so, I've =
made=20
> a mapping from old directories to new directories in the following =
manner:
> =A0
> Assume that you had a folder named "/foo/bob" and=A0the HTML =
files=A0"/foo/foo.
> html", "/foo/foo2.html"=A0and "/foo/bob/bob.html". The new site, =
however,=20
> contains the folder "/newfoo" as the corresponding for "foo" and =
"/newbob"
>  for the old "/foo/bob/". The corresponding docu for "/foo/foo.html" =
is=20
> "/newfoo/newfoo_html", while "/foo/foo2.html" does not have such a=20
> corresponding page and the index_html of "/newfoo" should be =
displayed.
> In this case you should make a mapping like:
> =A0
> mappings =3D [
> =A0=A0=A0 ('/foo/bob', '/newbob'),
> =A0=A0=A0 ('/foo/foo.html', '/newfoo/newfoo_html'),
> =A0=A0=A0 ('/foo', '/newfoo')
> ]
> =A0
> Iterating over the list and matching the actual REQUEST's URL to the =
first=20
> item of each tuple, the right URLs are constructed. Then the client =
has to=20
> be redirected to the new URL.Let's call the script doing the whole job=20=

> "redirector"
> =A0
> Then I changed my standard_error_message so that it first=A0invokes =
the=20
> redirector script in case of NotFound errors with the <dtml-call> tag.
> =A0
> What my problem is: the redirector script cannot be called, although =
it is=20
> in the same folder as standard_error_message, because Zope encounters =
a=20
> 404 error and displays its own standard error message.
> =A0
> Does any good fellow have any idea on how to call that script=20
> without=A0having Zope so crazy?
> =A0
> =A0
> Thanks in advance,
> e-Musty