[Zope-CMF] Accessing the "context"
Wichert Akkerman
wichert at wiggy.net
Tue Oct 30 13:06:05 EDT 2007
Previously Charlie Clark wrote:
>
> Am 30.10.2007 um 17:40 schrieb Wichert Akkerman:
>
> >__init__ is indeed the wrong place: when the instance is created it is
> >not placed in an acquisition context yet.
>
> That would indeed explain things!!! Is it okay to call a method which
> does this from __init__ ?
No, since the acquisition context is only created when the object is
insert into the hierarchy somewhere (sloppy terminology here, I know).
And that can only happen after the instance has been fully created.
As an example:
obj = Object()
# obj has no acquisition context
folder.obj = obj
# folder.obj will have an acquisition context
In other words: in __init__ and everything you call from __init__ the
instance will not have an aq context. The context does not magically
appear.
Wichert.
--
Wichert Akkerman <wichert at wiggy.net> It is simple to make things.
http://www.wiggy.net/ It is hard to make things simple.
More information about the Zope-CMF
mailing list