hi, ----- Original Message ----- From: "Jens Vagelpohl" <jens@dataflake.org> To: "[Zope] Mailing List" <zope@zope.org> Sent: Wednesday, August 02, 2006 12:52 PM Subject: Re: [Zope] adding product-based objects programmatically
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 2 Aug 2006, at 06:37, Kees de Brabander wrote:
Hi, Apparently my knowledge of Zope/Python is still to limited. I have a product that derives from Folder. When I add this product to a folder via zmi I want to have it populated with other products to it programmatically. I tried to do so in the __init__ function. That works with objects like acl_user folders, but not with products in the products directory. Can anyone send me in the right direction or at least give a hint where to look for a solution?
Do not do this in __init__ as you have no acquisition at that point. Use manage_afterAdd for that.
jens
Your remark appeared (and presumably is) valid, although I do not understand why adding acl_user folders has no problems with that. So, I additionally defined manage_afterAdd. However I got the same error. Any more pointers? By the way, where are 'manage_afterAdd' and friends documented? tia, cb Module QuerySet.py: from Query import manage_addQuery class QuerySet(Folder): def __init__(self, id, title): self.id = id self.title = title self.manage_addUserFolder() def manage_afterAdd(self, item, container): manage_addQuery(self, id, title) manage_addQuery in Query.py looks like: def manage_addQuery(dispatcher, id, title, REQUEST=None): "...." nQ=Query(id,title) dispatcher.Destination()._setObject(id, nQ) if REQUEST is not None: dispatcher.manage_main(dispatcher, REQUEST) Traceback (innermost last): a.. Module ZPublisher.Publish, line 101, in publish b.. Module ZPublisher.mapply, line 88, in mapply c.. Module ZPublisher.Publish, line 39, in call_object d.. Module Products.QuerySet.QuerySet, line 81, in manage_addQuerySet e.. Module OFS.ObjectManager, line 276, in _setObject f.. Module Products.QuerySet.QuerySet, line 114, in manage_afterAdd g.. Module Products.Query.Query, line 80, in manage_addQuery AttributeError: Destination zope 2.7.8, win32