[Zope-dev] New method for ZCatalog: recatalog_object

Steve Alexander steve@cat-box.net
Sun, 27 Aug 2000 14:35:34 +0100


ZCatalog would be easier to use if it had a recatalog_object method:

    def recatalog_object(self, obj, uid):
        """Adds object to the catalog if not already present.
        Removes old entry first, if already in present."""
        self.uncatalog_object(uid)
        self.catalog_object(obj, uid)

This, and a new method in Traverable.py would make cataloging in
ZPatterns SkinScript very easy indeed.

Add to Traversable.py:

    getPathAsString__roles__=None # Public
    def getPathAsString(self):
       '''Returns the physical path as a string.
       The returned string will always start with a slash.'''
       return join(self.getPhysicalPath(), '/')


Otherwise, ZCatalog could be altered to accept lists of strings as uid
method attributes, and automatically convert them into slash-separated
strings.

Example SkinScript:

WHEN OBJECT ADDED, CHANGED CALL Catalog.recatalog_object(self,
self.getPathAsString())
WHEN OBJECT DELETED CALL
Catalog.uncatalog_object(self.getPathAsString())

Any comments?

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net