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

e-Musty emusty@mailbox.hu
Tue, 29 Jan 2002 13:26:56 +0100


Jens, thanks for the really prompt response. However I have succeeded to
figure out the bug in my code, I've checked out your product and it is
really cool. I can tell everybody requiring such a functionality to use your
product!

By the way, the bug of which the existence you predicted was a silly bug,
instead of the lower() function of Python I called the lowercase(), that
caused the bugs :))

-----Original Message-----
From: Jens Vagelpohl [mailto:jens@zope.com]
Sent: 2002. január 29. 3:43
To: emusty@mailbox.hu
Cc: Zope Zope Listserver
Subject: Re: [Zope] Smart redirecting? Help me in a script call in
standard_error_message


if you get the "built-in" error page even though you call your own script
it is likely that executing your script produces errors. in that case zope
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
gives you the redirect URL and do the redirect manually. it keeps logs of
requests that go through it (with a management interface to display simple
stats about the log) and has an easy management interface to define new
"old url: new url"-mappings with selectable HTTP response status codes.

the product is at http://www.dataflake.org/software/jredirector . i'm using
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
> 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