[Zope] redirect to a renamed folder
Fri, 21 Jun 2002 17:08:41 -0400
Maybe this is what you want:
I haven't tried it.
On Fri, Jun 21, 2002 at 07:45:39PM +0100, Tim Hicks wrote:
> Now I'm pretty sure this is some sort of faq, but I'm really having trouble
> doing what I thought would be simple.
> The Problem:
> I have a site which needs to have one of its subfolders renamed from (say)
> 'foo' to 'bar'. All subfolders within 'foo' (now 'bar') are the same. No
> problem so far, but people will have the old url's bookmarked, so I want to
> redirect people requesting for example: /site/foo/blacksheep to
> What I've Tried:
> I figured I'd user standard_error_message to catch 'NotFound' errors, and
> perform a redirect. This is proving more difficult than I'd anticipated.
> Here is what I came up with:
> <dtml-if "error_type">
> <dtml-if "error_type == 'NotFound'">
> <dtml-let new_path="_.string.join(_.string.split(error_value, '/')[2:],
> <dtml-call "RESPONSE.redirect('http://192.168.2.2:9980/test/'+new_path,
> status=301, lock=1)">
> missed it
> The problem is, this seems to redirect to something looking like
> http://192.168.2.2:9980/test/H2> (including the >). I guess 'error_value'
> is not the variable I want. I thought maybe I would want
> TraversalRequestNameStack, but that doesn't appear right either. Really, I
> want a list of url segments so I can drop in my new folder name in place of
> the old one, rebuild the url then redirect, but I'm not sure how to do that.
> Any ideas?
> ps Another way I thought of was to maintain an empty folder named 'foo' with
> an accessrule python script in it that catches the traverse_subpath and does
> a redirect, but I'm not sure if that should even work in theory. I haven't
> used accessrules before, and I had trouble getting things to work. From the
> archives, I found that I can't use RESPONSE.redirect() from an accessrule,
> but have to use raise. However, I couldn't get this to work either.
> Zope maillist - Zope@zope.org
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-dev )
"Muppet Labs, where the future is made - today!"