[Zope] Puzzled re ZCatalog and Zope.org /SiteIndex

Mike Pelletier mike@digicool.com
Wed, 3 Nov 1999 10:48:37 -0500


Jeff Rush <jrush@timecastle.net> wrote:
> >> [1] Some areas I'm having trouble on are the metadata and index fields
> >> used in DTML that accesses the SiteIndex zcatalog object.  They use
> >> search fields like 'date', 'url', 'title_or_id' and 'text_content'
which
> >don't
> >> exist in a default zcatalog instance.  I can add them via the
management

> >    No, it is a completely plain-jane ZCatalog.  Those are external
methods.
> >In the cases of the Z Classes, they are members of the class.  Vanilla
Zope
> >objects like DTML Documents are acquiring those methods from a parent
> >folder.

> Hmmm, I don't quite understand.  Are you saying that ya'll created and
> placed in the root folder, say, an external method named 'date' that does
> the equivalent of the following in a DTML Method
>
>      <dtml-return bobobase_modification_time>
>
> And then you added a field called 'date' to the ZCatalog metadata
> and index tabs?

    Yes.

> This seems to work here with a DTML Method -- why was an external
> method necessary?

    Good question.  It was there when I got here.  ;-)  It's probably
faster.

>  Also doesn't this mean that the ZCatalog instance
> is duplicating data, storing the date under both the
'bobobase_modification_time'
> (for backward compatibility) and 'date' columns?  This seems like a bit
> of overhead just to be able to use the shorter name in search DTML,
> or am I missing the benefit/intent?

    I think 'date' was chosen to make the SiteIndex conform to a specific
spec, which I don't know anything about.  I'm going to have to leave these
questions to Amos, who (I think!) did most the SiteIndex and external method
stuff.

> {also to construct the 'url' attribute, how did you obtain the url of an
arbitrary
>  object -- the generic Zope equivalent of "getpath(record_id)"?}

    Here is the code behind url.  Hopefully Outlook Express won't mangle it
beyond recognition.

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']
    if script_name:
        uri=filter(None, string.split(uri, script_name))[0]
    uri=uri or '/'
    if uri[0]=='/': uri=uri[1:]
    return uri

> -Jeff Rush

Mike.