----- Original Message ----- From: "Dieter Maurer" <dieter@handshake.de> To: "Kees de Brabander" <cj.de.brabander@hccnet.nl> Cc: "Jens Vagelpohl" <jens@dataflake.org>; "[Zope] Mailing List" <zope@zope.org> Sent: Friday, August 04, 2006 8:11 PM Subject: Re: [Zope] adding product-based objects programmatically
Kees de Brabander wrote at 2006-8-3 20:39 +0200:
... adding additional objects ... Thanks anyway, problem solved, even when done in the __init__ of Queryset. Would manage_afterAdd a more sensible place for it?
You cannot do it in "__init__" when the object needs a correct acquisition chain (which is not the case in "__init__"). This is the case, for example, when the object needs to be indexed.
When you add further objects in "manage_afterAdd", you have to be aware, that "manage_afterAdd" is not only called when the object is initially created but also for rename/move/copy. In all those cases, your objects are likely to be already there. This means that you have explicitely to check for this case.
Googling and puzzling I became aware of that fact. Thanks for your concern. cb