Dear Zopers The Zope Book explains the use of ZCatalog for indexing and searching (http://zope.org/Documentation/Books/ZopeBook/2_6Edition/SearchingZCatalog.st...). However, I want to use Catalog (and not ZCatalog) in my file-system-based product. I use a Folder object to which I add custom objects using self._setObject(id, item). Does anybody have a good example of what is needed for this purpose? What are the preconditions for indexing/searching in this context? thanks a lot for your help Andre
Andre Meyer wrote:
Dear Zopers
The Zope Book explains the use of ZCatalog for indexing and searching (http://zope.org/Documentation/Books/ZopeBook/2_6Edition/SearchingZCatalog.st...).
However, I want to use Catalog (and not ZCatalog) in my file-system-based product. I use a Folder object to which I add custom objects using self._setObject(id, item).
Does anybody have a good example of what is needed for this purpose? What are the preconditions for indexing/searching in this context?
"ZCatalog" is the class name. Normally you have an instance of this class with the id of "Catalog" I that case you only need to subclass CatalogAware: from Products.ZCatalog.CatalogPathAwareness import CatalogAware class AProduct(CatalogAware, other mixins...): etc... regards Max M
Andre Meyer wrote at 2004-3-4 15:03 +0100:
The Zope Book explains the use of ZCatalog for indexing and searching (http://zope.org/Documentation/Books/ZopeBook/2_6Edition/SearchingZCatalog.st...).
However, I want to use Catalog (and not ZCatalog) in my file-system-based product. I use a Folder object to which I add custom objects using self._setObject(id, item).
"ZCatalog" is essentially a configuration device for the "Catalog". Searching, indexing, adding columns and indexes essentially work for "Catalog" as they do for "ZCatalog". You are using "Catalog" in an "unsupported" way. Therefore, you must expect to look at its (and that of ZCatalog) code from time to time to find out some relevant details. -- Dieter
Thanks for your help. With your help I have added a ZCatalog to my product and some indexes to it. Next question is how to add new items to the indexes as they are created and edited. CatalogAware alone does not seem to be sufficient. Here is what I have so far: ------------------------------------------------------------------------ from Products.ZCatalog import ZCatalog ... class MusicLibrary(Folder): "A Zope Folder for the objects of the Music Library" meta_type = "Music Library" def __init__(self, id, title, description = ""): ... self._catalog = ZCatalog.*ZCatalog*('Catalog') self._catalog.*addIndex*('path_index', 'PathIndex') self._catalog.*addIndex*('text_index', 'TextIndex') self._catalog.*addIndex*('field_index', 'FieldIndex') self._*setObject*('Catalog', self._catalog) ... def addItem(self, id, item): self._*setObject*(id, item) self.category = None self._catalog.*catalog_object*(item) # does not work yet !!! ------------------------------------------------------------------------ from Products.ZCatalog.CatalogPathAwareness import CatalogAware ... class Composer(SimpleItem, *CatalogAware*): ... ------------------------------------------------------------------------ Any ideas or examples? Your help is appreciated. thanks Andre Dieter Maurer wrote:
Andre Meyer wrote at 2004-3-4 15:03 +0100:
The Zope Book explains the use of ZCatalog for indexing and searching (http://zope.org/Documentation/Books/ZopeBook/2_6Edition/SearchingZCatalog.st...).
However, I want to use Catalog (and not ZCatalog) in my file-system-based product. I use a Folder object to which I add custom objects using self._setObject(id, item).
"ZCatalog" is essentially a configuration device for the "Catalog". Searching, indexing, adding columns and indexes essentially work for "Catalog" as they do for "ZCatalog".
You are using "Catalog" in an "unsupported" way. Therefore, you must expect to look at its (and that of ZCatalog) code from time to time to find out some relevant details.
Andre Meyer wrote:
self._catalog = ZCatalog.*ZCatalog*('Catalog')
storing this in self._catalog is pointless, don't do it...
self._catalog.*addIndex*('path_index', 'PathIndex') self._catalog.*addIndex*('text_index', 'TextIndex') self._catalog.*addIndex*('field_index', 'FieldIndex') self._*setObject*('Catalog', self._catalog)
Okay, CatalogAware should find this catalog if "Composers" are added inside "Music Libraries", are they?
... def addItem(self, id, item):
How are you calling this method? It doesn't feel right, and may be what is causing CatalogAware's manage_afterAdd method not to get fired...
self._catalog.*catalog_object*(item) # does not work yet !!!
...but this line should work, although you should access it as "self.Catalog" once you've done what I suggested above...
Any ideas or examples? Your help is appreciated.
Don't post HTML to a Non-HTML list for starters ;-) Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Hi Chris With the help of Siegmund Fuhringer I managed to get this right, so far: Yes, self._catalog is not necessary. Items not being added to indices happened because the items lacked a method to deliver a value to the appripriate indices. This works now, but I have not seen this documented anywhere... Non-HTML this time :-) thanks to everyone! best wishes Andre ...and now for something completely related: searching... Chris Withers wrote:
Andre Meyer wrote:
self._catalog = ZCatalog.*ZCatalog*('Catalog')
storing this in self._catalog is pointless, don't do it...
self._catalog.*addIndex*('path_index', 'PathIndex') self._catalog.*addIndex*('text_index', 'TextIndex') self._catalog.*addIndex*('field_index', 'FieldIndex') self._*setObject*('Catalog', self._catalog)
Okay, CatalogAware should find this catalog if "Composers" are added inside "Music Libraries", are they?
... def addItem(self, id, item):
How are you calling this method? It doesn't feel right, and may be what is causing CatalogAware's manage_afterAdd method not to get fired...
self._catalog.*catalog_object*(item) # does not work yet !!!
...but this line should work, although you should access it as "self.Catalog" once you've done what I suggested above...
Any ideas or examples? Your help is appreciated.
Don't post HTML to a Non-HTML list for starters ;-)
Chris
Andre Meyer wrote:
Items not being added to indices happened because the items lacked a method to deliver a value to the appripriate indices. This works now, but I have not seen this documented anywhere...
http://zope.org/Documentation/Books/ZopeBook/2_6Edition/SearchingZCatalog.st... cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
participants (4)
-
Andre Meyer -
Chris Withers -
Dieter Maurer -
Max M