[Zope-dev] ZCatalog 'url' bug??
David Kankiewicz
kankie@thegrid.net
Thu, 16 Dec 1999 07:40:37 -0800
OK try this (well don't unless you want undeletable objects)
create something that is CatalogAware, than have it index itself
"index_object" (when being created, inside a factory I think?), now
clear your catalog and use "Find Items to ZCatalog" to index the same
object. Lastly try to delete the object, Zope complains can't uncatalog
the object and it won't delete it.
The uid or rid or data_record_id_ (can somebody make up their "minds"?)
is first indexed WITHOUT the leading '/' and than with it if we "Find
Items ..."
Would:
url='%s/%s' % (self.DestinationURL(), self.id)
not return a leading '/'? If so, would
url='/%s/%s' % (self.DestinationURL(), self.id)
fix it? Else could somebody add a test to see if 'uri' has a '/' in the
front and ignore the problem...
relevant CatalogAwareness.py:
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
def index_object(self):
"""A common method to allow Findables to index themselves."""
if hasattr(self, self.default_catalog):
getattr(self, self.default_catalog).catalog_object(self,
self.url())
Maybe relevant FactoryDispatcher.py
class FactoryDispatcher(Acquisition.Implicit):
" "
def __init__(self, product, dest, REQUEST=None):
if hasattr(product,'aq_base'): product=product.aq_base
self._product=product
self._d=dest
if REQUEST is not None:
v=REQUEST['URL']
v=v[:rfind(v,'/')]
self._u=v[:rfind(v,'/')]
def DestinationURL(self):
"Return the URL for the destination for factory output"
return self._u