[Zope-dev] bug in CatalogAwareness?

Steve Alexander steve@cat-box.net
Thu, 24 Aug 2000 16:41:17 +0100


Shane Hathaway wrote:
> 
> Steve Alexander wrote:
> > In lib/python/Products/ZCatalog/CatalogAwareness.py, the method "url":
> >
> >     def url(self, ftype=urllib.splittype, fhost=urllib.splithost):
> >         """Return a SCRIPT_NAME-based url for an object."""
> >         if hasattr(self, 'DestinationURL') and \
> >            callable(self.DestinationURL):
> >             url='%s/%s' % (self.DestinationURL(), self.id)
> >         else: url=self.absolute_url()
> >         type, uri=ftype(url)
> >         host, uri=fhost(uri)
> >         script_name=self.REQUEST['SCRIPT_NAME']
> >         __traceback_info__=(`uri`, `script_name`)
> >         if script_name:
> >             uri=filter(None, string.split(uri, script_name))[0]
> > *       if uri[0] != '/': uri = '/' + uri
> > *       uri=uri or '/'
> >         return urllib.unquote(uri)
> >
> > I'm suspicious of the two lines marked with a "*".
> 
> I was suspicious of the entire method so I wrote a replacement which is
> based on a new interface available in Zope.  I *think* it's correct,
> but it's a drastic change so it's only in the new PTK and nowhere
> else.  (This is slightly modified from PTK CVS.)
> 
>     def __url(self):
>         return string.join(self.getPhysicalPath(), '/')

That certainly looks a lot cleaner and more obvious.

Does it work with SiteAccess?

What's with all the DestinationURL stuff in the original url method?

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net