[Zope] Building dynamically class instances using external methods.
Dieter Maurer
dieter@handshake.de
Tue, 14 Nov 2000 23:59:04 +0100 (CET)
Hannes Grund writes:
> I have an external Method
> which creates dynamically an instance from of a class depending on
> some input to a function contained in this method.
> In short the code (of the external method)
>
> class Classname:
> ....
> Called from Zope this does not work. The pickle module raises an
> error:
The External Method documentation tells you that you may
not define a class inside the the source file and return
instances thereof into the Zope world.
Place such classes in standard Python module files
(the documentation suggests a subpackage in "Shared")
and import them in your external method source file.
> QUESTION 3: The lifetime of an instance has should not to be longer than
> the current REQUEST is performed, is there any possibility to
> create the instance as an subobject of the current REQUEST ??
self.REQUEST.set('xxx', <your instance>)
Dieter