[Zope-dev] RE: ZCatalog

Michel Pelletier michel@digicool.com
Wed, 14 Jul 1999 18:44:04 -0400


> -----Original Message-----
> From: Jason Spisak [mailto:webmaster@mtear.com]
> Sent: Wednesday, July 14, 1999 5:45 PM
> To: Michel Pelletier
> Cc: zope-dev@zope.com
> Subject: Re: ZCatalog
> 
> 
> Michel,
> 
> I'm using the following external method because without it the Catalog
> won't let an object index itself.  It's the one you sent me, 
> but I get a
> NameError when I call urllib. Is there a special import I 
> have to do to
> get access to urllib? Just
> out of curiousity(mostly because I know very little python), 
> why return
> a script_name based url.
> 

yes sorry, you'll need to import urllib and string.

This is the method we use to catalog our objects in the Portal Tool Kit.

-Michel

> 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]
>     uri=uri or '/'
>     if uri[0]=='/': uri=uri[1:]
>     return uri
> 
> All my best,
> 
> Jason Spisak
> webmaster@mtear.com
>