Deleting an object from ZCatalog search results
Hi, What do you consider to be the easiest way to delete an object "returned" in a ZCatalog search. I can get the object by using getObject on the data_record_id_, but how can I delete it? Do I need to do some sort of traversal to the folder that contains the object? Is there a method for an object to delete itself? Something like <dtml-call "object.self_destruct()"> Thanks in advance, Nuno
Hi! You can uncatalog it, only. I think that isn't necessary to delete the object.
From Python, something like this works: Products.ZCatalog.ZCatalog.ZCatalog.uncatalog_object(your_catalog, object_to_uncatalog)
(importing Products) Best regards, Paula Mangas On Mon, 4 Feb 2002, Nuno Maltez wrote:
Hi,
What do you consider to be the easiest way to delete an object "returned" in a ZCatalog search. I can get the object by using getObject on the data_record_id_, but how can I delete it?
Do I need to do some sort of traversal to the folder that contains the object?
Is there a method for an object to delete itself? Something like
<dtml-call "object.self_destruct()">
Thanks in advance, Nuno
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Em Segunda, 4 de Fevereiro de 2002 14:47, Paula Mangas escreveu:
You can uncatalog it, only. I think that isn't necessary to delete the object.
But what I really want to do is to delete the damn thing :-) And hope that, being a catalogAware object, the unCatalog part will happen automatically. Thanks anyway, Nuno
Hi! If you want to delete the object, you have the delObject method... _delObject(father_folder, object_id) I hope this help, Paula Mangas PS: note that the object will stay in ZODB... if you want, you can do an undo. That can be done until you pack the database. On Mon, 4 Feb 2002, Nuno Maltez wrote:
Em Segunda, 4 de Fevereiro de 2002 14:47, Paula Mangas escreveu:
You can uncatalog it, only. I think that isn't necessary to delete the object.
But what I really want to do is to delete the damn thing :-)
And hope that, being a catalogAware object, the unCatalog part will happen automatically.
Thanks anyway, Nuno
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Em Segunda, 4 de Fevereiro de 2002 16:11, Paula Mangas escreveu:
Hi! If you want to delete the object, you have the delObject method...
_delObject(father_folder, object_id)
I understand that, but what I really want to know is if there's an easy way of getting the "father_folder" of an object. My cataloged objects could be anywhere in the ZODB Tree. Is there a parent attribute or something that I can use from "inside" (<dtml-with...>) an object? Thanks again, Nuno
Nuno Maltez writes:
What do you consider to be the easiest way to delete an object "returned" in a ZCatalog search. I can get the object by using getObject on the data_record_id_, but how can I delete it?
Do I need to do some sort of traversal to the folder that contains the object?
Is there a method for an object to delete itself? Something like
<dtml-call "object.self_destruct()"> Now, the method is not on the object but on the container and is called "manage_delObjects". It takes a sequence (!) or ids and deletes the specified subobjects.
Thus, you problem is how to get at the container, given the object. Depending on how "getObject" wraps the returned object "getObject(...).aq_parent" may work. If it does not work, you need to use "getObject(...).aq_inner.aq_parent "aq_inner" is not exposed to DTML/Python Scripts (a bug in my view). Thus, you need an External Method or something similar. Dieter
participants (3)
-
Dieter Maurer -
Nuno Maltez -
Paula Mangas