Andrew Kenneth Milton <akm@theinternet.com.au> wrote:
If someone gives me a sane reason why this isn't correct and that calling self = self.this() in every product constructor is actually the correct behaviour I'll put it in (as opposed to catering for lazy ZClass programmers d8) Not that this seems to be in very many constructors for Zope stuff or other products I have installed.
Since it seems this is going to occur repeatedly, having spent 10 seconds looking at it, it seems that the 'correct' way is to call
self.Destination()._setObject()
so in essence self.Destination().__allow_groups__ will also get what we want.
This is actually documented (although it's not clear what versions of Zope this will work with, or whether this will do the same thing as self._setObject(), it's late, I've had no sleep, I'll look later, or someone who actually knows can fill in the blanks for us, but, I think it's 2.4 only)
Yes, here is the idiom I now use everywhere, according to what I read in the code and documentation: def addFoo(dispatcher, id, REQUEST=None, **kw): """ Adds a Foo. """ ob = Foo(id) container = dispatcher.Destination() container._setObject(id, ob) if REQUEST is not None: dispatcher.manage_main(dispatcher, REQUEST) In any case calling the first argument "self" is really overloading the meaning of the word, as we are nowhere near a method here. Florent -- Florent Guillaume, Nuxeo (Paris, France) +33 1 40 33 79 10 http://nuxeo.com mailto:fg@nuxeo.com