overriding manage_beforeDelete in a CatalogAware Product
I think I need help in overriding the manage_beforeDelete method from CatalogAware. Just to be sure I'm asking the right question, here's the background: I have a Product (in Python, not TTW) whose instances get cataloged in a separate ZCatalog called CommentCatalog. My product's class inherits from CatalogAware and other classes and can successfully index itself by calling thusly in the __init__ routine: self.manage_editCataloger('CommentCatalog') self.index_object() Reindex also works just fine. But I'm confused about how to get rid of the index entry upon delete. I think I need to set the catalog name and then call the inherited manage_beforeDelete routine. So I tried this: def manage_beforeDelete(self, item, container): "Be sure we unindex ourselves from our special catalog" self.manage_editCataloger('CommentCatalog') self.CatalogAware.manage_beforeDelete(item, container) Not too surprisingly, the code throws an "AttributeError: CatalogAware" into the Stupid Log File and doesn't remove the object from CommentCatalog. Of course I don't understand what the correct incantation is, so I'm appealing for guidance. Zope 2.2.2, Python 1.5.2, RH 6.2, etc Thanks! -- Dennis Nichols nichols@tradingconnections.com
But I'm confused about how to get rid of the index entry upon delete. I think I need to set the catalog name and then call the inherited manage_beforeDelete routine. So I tried this:
def manage_beforeDelete(self, item, container): "Be sure we unindex ourselves from our special catalog" self.manage_editCataloger('CommentCatalog') self.CatalogAware.manage_beforeDelete(item, container)
Not too surprisingly, the code throws an "AttributeError: CatalogAware" into the Stupid Log File and doesn't remove the object from CommentCatalog. Of course I don't understand what the correct incantation is, so I'm appealing for guidance.
You should just be able to do "self.manage_beforeDelete(..)" since you have inherited all CatalogAware's methods. Make sure you have CatalogAware as your first (left most) item in your classes inheritance. Do you really need to set the catalog again? Isnt that already set in your class? -- Andy McKay, Developer. ActiveState.
At 11/17/00 09:04 AM, Andy McKay wrote:
But I'm confused about how to get rid of the index entry upon delete...
You should just be able to do "self.manage_beforeDelete(..)" since you have inherited all CatalogAware's methods. Make sure you have CatalogAware as your first (left most) item in your classes inheritance.
This might be right, but I didn't try it because next Andy said:
Do you really need to set the catalog again? Isnt that already set in your class?
I think I get a big "Well, duh!" here. Of course, if I do a "self.manage_editCataloger(...)" in my product's __init__ routine, that sets the catalog for the rest of the object's existence, not just the __init__ routine. And so I don't have to set it again in any edit routine, nor do I have to worry about the object's deletion. Tested and working. Many thanks. -- Dennis Nichols nichols@tradingconnections.com
participants (2)
-
Andy McKay -
Dennis Nichols