[Zope-dev] bug in CatalogAwareness?
Shane Hathaway
shane@digicool.com
Thu, 24 Aug 2000 12:53:58 -0400
Steve Alexander wrote:
>
> 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?
Untested, but it should work, yes.
> What's with all the DestinationURL stuff in the original url method?
That would be related to product factories. When you're accessing
"http://someserver/somepath/manage_addProduct/productName/factoryName",
the path is supposed to simplify down to
"http://someserver/somepath/someid". I don't know whether
getPhysicalPath() deals with that situation the same way, but it
probably should if it doesn't.
Shane