[Zope-dev] Re: ZCatalog
Jason Spisak
webmaster@mtear.com
Wed, 14 Jul 1999 13:51:08 -0800
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.
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