[Medusa-dev] redirecting_handler bug fixed

A.M. Kuchling amk@amk.ca
Mon Nov 25 01:02:20 2002

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)
         new_url = self.redirect

Seem reasonable?

--amk                                                             (www.amk.ca)
To Sherlock Holmes she is always *the* woman.
      -- From "A Scandal in Bohemia"

More information about the Medusa-dev mailing list