I need to convert a ZClass cataloged in multiple ZCatalogs into a Product. I know how to create a Product. But I have trouble understanding how to create a proper ZCatalog and manage it in a Product.

When I change my ZClass instance, it reindexes itself in multiple ZCatalogs. I have the following DTML method "edit" in my ZClass (stored in ZODB) that takes care of this:

<dtml-call "manage_editCataloger('Catalog_A')">
<dtml-call reindex_object>
<dtml-call "manage_editCataloger('Catalog_B')">
<dtml-call reindex_object>

How should this be programmed in Products?

- Should I first create a ZCatalog instance in ZODB, and then bind this instance to my Product? That would make my Product not self-contained.

- or should the Product rather create ZCatalog instance during its initialization? That would mean that upon Zope restart, ZCatalog instance would be removed and re-created and all Product instances would have to be recataloged.

In my new Product (that is to replace my ZClass), I put this line:

from Products.ZCatalog.ZCatalog import ZCatalog

and I added ZCatalog to the list of subclassed classes:

class ArtBase(ZCatalog, ObjectManager, SimpleItem, PropertyManager, JMZPTMacros):

but I have no idea what to do next. In this mailing list's archive, Chris Withers wrote that ZCatalog should be an attribute of a product's instance so that I can open the ZCatalog management interface by calling "my_prod_instance/catalog_name/manage". I understand that, but I have no idea how to achieve it.

Should I add a line to my class __init__ ? Something like:

  def __init__(self,id,title=''):
    """Contructor method to initialize the properties of our class"""
    #Create and initilize the class attributes
    self.catalog=manage_addZCatalog(id="catalog", title="title")

but the above looks fishy because I would have an isolated catalog for each new instance of my class...

To support manage_editCataloger and reindex_object, do I need to import both ZCatalog from Products.ZCatalog and CatalogAware from Products.ZCatalog.CatalogAwareness ?

Milos Prudek
Zope maillist - Zope@zope.org
** No cross posts or HTML encoding! **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to