Sorry if this arrives twice, but mailing lists seem to have swallowed my
earlier mail.

I've been playing around with ZPatterns, and I must say it's very cool -
finally you can mix ZCatalog and SQL storage.  CatalogAwareness is slightly
different than regular Zope objects in that you have to find the ZCatalog in
the Rack's acquisition path, but that's about it.

The absolute_url function I define here should be moved to the RackMountable
class since it may be useful in other situations.


from Products.ZCatalog.CatalogAwareness import CatalogAware
from Products.ZPatterns.Rack import _v_rack, RackMountable

class RMCatalogAwareMixIn(CatalogAware):
    CatalogAwareness for RackMountables.
    You need to inherit from this class before RackMountable.

    Objects are NOT automatically indexed, because no rack has
    been defined when we're in __init__.
    def absolute_url(self, relative=0):
        """ URL for catalog-awareness """
        return "%s/%s" % (self._v_rack.absolute_url(relative),
    def index_object(self):
        """A common method to allow Findables to index themselves."""
        if hasattr(self._v_rack, self.default_catalog):
            getattr(self._v_rack, self.default_catalog).catalog_object(self,
    def unindex_object(self):
        """A common method to allow Findables to unindex themselves."""
        if hasattr(self._v_rack, self.default_catalog):
    def manage_delete(self, _v_rack=_v_rack):
        """ Uncatalog this object and then delete it """
        return RackMountable.manage_delete(self, _v_rack)

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to