[Zope] speeding up dtml-tree <00b001c006da$d19c4310$6703a8c0@torch>

Dieter Maurer dieter@handshake.de
Fri, 25 Aug 2000 20:51:10 +0200 (CEST)


Clinton Roy writes:
 > .... external method restrictions ....
 > I'm losing faith people..

Maybe, you should not.

There are more ways to build extensions than external methods
in "Extension" directories.

Each way has its advantages and drawbacks:

Type		Web Manageable	  		requires restart

DTML Methods	     yes				no

ZClasses	     yes				no

External methods    partly				no

Products	    partly			        yes

Python Modules       no					yes



The restrictions for source files in the Extension directories
are documented together with a description what to do
to circumvent the restrictions:

   These source files are not imported as standard Python
   modules but they are read in and executed.

   As a consequence, Zope may simply reread and
   reexecute them when they changed. A restart
   is not necessary.
   If they could be used like full Python modules,
   then it would be very difficult to do this
   in a safe manner unless the Python import
   and lookup mechanisms are changed.
   This might be possible but difficult.

   On the downside, instances of classes defined in these
   source files can not be pickled (and therefore stored
   in the ZODB). The pickle mechanism does not
   understand Zope's read and execute but
   requires standard Python module import.

   The workaround: define the classes (!) you need
   for ZODB objects in true Python modules.
   The documentation suggests to define them
   in a properly named subpackage of "Shared" such that
   maintenance will not become a nightmare.
   Yes, changes to true Python modules (and therefore
   to your classes) require a Zope restart.
   But, hopefully, you will not change your classes
   too often.

   You can instantiate your classes, i.e. build
   instances from them, in external methods,
   i.e. in source files located in an Extension
   folder.

   There is no need to have the same code at two
   places! Classes for picklable objects or
   infrastructure to be used in several source
   files in true Python modules,
   everything else (if you want) in external methods.


Each tool has its strengthes and weaknesses. Know them
and use the right tool for your task.
This applies both to (sub-)tools inside Zope
(e.g. external method versus product versus Python module)
as well as to Zope itself (versus ASP, PHP, JSP, ...).


Dieter