Re: [Zope-dev] CatalogAwareness for RackMountables
At 12:53 PM 5/30/00 +0300, Itamar Shtull-Trauring wrote: >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. IMHO, you don't need to keep referring to self._v_rack to do the cataloging as described, so long as you retrieve your objects from a Specialist; then the acquisition path is via the Specialist. I would suggest that you modify your patches somewhat to reflect this, and use only self.* attributes, not self._v_rack.*. It will improve your forward-compatibility with 0.4.0. >The absolute_url function I define here should be moved to the RackMountable >class since it may be useful in other situations. I have to disagree with this, since the standard Zope absolute_url method will work correctly, so long as you access a RackMountable by traversing (via bobo_traverse) from a Specialist. If you would like to make your work easier with version 0.3.0, it would be best for you to move the __of__ wrapping from Specialist.__bobo_traverse__() to Specialist.getItem(), as I have done in the working copy of 0.4.0. This will ensure that whenever you retrieve a rackmountable from a Specialist, it will be wrapped in context of the Specialist. Then, by deriving your classes from RackMountable and CatalogAware, you need only adjust for the absence of add and delete hooks. And you'll only need to adjust for that until 0.4.0 makes add/change/delete hooks available for indexing agents. I don't know if there will be a Catalog IndexAgent released with 0.4.0 yet, but there should be one eventually (or perhaps someone will contribute one). ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] CatalogAwareness for RackMountables
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), self.id) 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, self.url()) def unindex_object(self): """A common method to allow Findables to unindex themselves.""" if hasattr(self._v_rack, self.default_catalog): try: getattr(self._v_rack, self.default_catalog).uncatalog_object(self.url()) except: pass def manage_delete(self, _v_rack=_v_rack): """ Uncatalog this object and then delete it """ self.unindex_object() return RackMountable.manage_delete(self, _v_rack) ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] CatalogAwareness for RackMountables
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), self.id) 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, self.url()) def unindex_object(self): """A common method to allow Findables to unindex themselves.""" if hasattr(self._v_rack, self.default_catalog): try: getattr(self._v_rack, self.default_catalog).uncatalog_object(self.url()) except: pass def manage_delete(self, _v_rack=_v_rack): """ Uncatalog this object and then delete it """ self.unindex_object() return RackMountable.manage_delete(self, _v_rack) ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )