[Medusa-dev] redirecting_handler bug fixed
SergioFernández
sfmunoz@teleline.es
Mon Nov 25 07:18:30 2002
On Sun, 24 Nov 2002 20:02:20 -0500
"A.M. Kuchling" <amk@amk.ca> wrote:
> On Sun, Nov 24, 2002 at 05:55:57PM +0100, Sergio Fernández wrote:
> > def handle_request (self, request):
> > self.hits.increment()
> > m = self.patreg.match (request.uri)
> >- part = m.group(1)
> >+ part = m.group()
> >
> > request['Location'] = self.redirect % part
>
> I don't like this patch because it changes behaviour and will break
> existing code that uses redirecting_handler. The intention of the
> code is that the pattern has a group in it,
> e.g. /long/url/directory/(.*), and the redirect would then be
> something like /newdir/%s, so /long/url/directory/foo.html will be
> redirected to /newdir/%s. This should be clarified in a docstring
> for the redirecting_handler class.
>
> I think you could use a pattern like /foo/bar/() if you don't need to
> get part of the original URL. Or maybe the code should be something
> like this:
>
> if self.patreg.groups > 0:
> new_url = self.redirect % self.patreg.group(1)
> else:
> new_url = self.redirect
>
> Seem reasonable?
>
> --amk
OK. It seems I didn't understand the way to use this handler. I have
followed your explanations and it works fine. I agree with you: it
should be clarified in a docstring for the redirecting_handler class.
Thank you.
Sergio
More information about the Medusa-dev
mailing list