Hi!

   I already got it! :) I imported earlier zexp and removed default args
from the External Method. The site now seems to do export/import
flawlessly.

   As I said, it's undocumented misfeature. Thanks for documenting it. Can
you make it a Tip or a HOWTO and publish it on zope.org?

On Sun, 3 Dec 2000, Dieter Maurer wrote:
> Oleg Broytmann writes:
>  > .... functions as default parameters to external method functions
>  > cause import problems ....
>  > ....
>  >    "Cannot import default_render from module __main__". Oops! What's that?
>  > The default_render isn't in __main__, sure. I tried to create External
>  > Method before importing, but this didn't help :(
> This is a severe danger of "pickle" and the external method
> implementation:
>
>   *  the implementation does not import the Python source files
>      but reads them in and executes them.
>
>      All functions and classes appear to be defined in the
>      module "__main__".
>
>   *  The implementation places the function default arguments
>      into the ZODB (as a pickle).
>
>   *  "unpickle" cannot load the corresponding object,
>      as it imports "__main__" and looks there for the
>      function -- in vain.
>
>
> As a rule:
>
>   Avoid the use of class of function definitons from
>   an external method source file for anything that
>   may be written to the ZODB (or more generally
>   be pickled; this applies e.g. to session context, too).
>   This includes created object instances that may
>   end up as attributes of Zope objects or
>   function default parameters to external methods.
>
> If you defined such classes or functions in a true
> Python module, you should have no problem.
>
>
>
> What can you do, if your zexp is valuable?
>
>   *  put a dummy definition of "default_render" in the
>      "__main__" module.
>
>      You should then be able to import your zexp
>      and change the problematic external method.
>
>      I do not know precisely, what Zope's "__main__"
>      module is. I expect the "z2.py".
>      If this is not the case, then a small dummy product
>      that does "import __main__; __main__.default_render= 0"
>      should do the trick, whatever "__main__" may be.

Oleg.
----
     Oleg Broytmann     http://www.zope.org/Members/phd/     [EMAIL PROTECTED]
           Programmers don't die, they just GOSUB without RETURN.


_______________________________________________
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )

Reply via email to