-----BEGIN PGP SIGNED MESSAGE-----
Wichert Akkerman wrote:
> 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).
Minor nit: the acquisition wrappers are transient objects, created when
the object is retrieved from the container (typically via the
container's __getattr__). So, the typical pattern for a factory which
needs to do something with context is:
def foo_factory(container, name):
foo = Foo(name)
wrapped = container._getOb(foo)
# now we have context
> 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
Right, but the original 'obj' doesn't magically get a context: you need
to re-fecth it (via 'foo.obj').
> In other words: in __init__ and everything you call from __init__ the
> instance will not have an aq context. The context does not magically
Tres Seaver +1 540-429-0999 [EMAIL PROTECTED]
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
Zope-CMF maillist - Zope-CMF@lists.zope.org
See http://collector.zope.org/CMF for bug reports and feature requests