[Zope-dev] Re: [Zope-CMF] How to get Type in manage_afterAdd?
Dieter Maurer
dieter@handshake.de
Fri, 1 Feb 2002 20:27:42 +0100
Florent Guillaume writes:
> Anyway I'd propose the following: we need, in constructInstance, to
> somehow pass the portal_type to the object constructor. Unfortunately
> this has to be backwards-compatible with all the constructors out there
> that don't know about it. I see two possible ugly solutions to do it:
>
> - do "constructor.__portal_type = portal_type" before calling
> constructor(...), and the constructor does something like:
> def manage_addFoo(...):
> try:
> portal_type = manage_addFoo.__portal_type
> manage_addFoo.__portal_type = None
> except:
> portal_type = None
Usually, this dynamic modification is not a good idea in a multi-threaded
environment.
If "constructor" is (part of) a persistent object, it might work in
Zope but may entail unnecessary writes to the ZODB.
Dieter