[Zope] Using Classes in Python scripts

Dieter Maurer dieter@handshake.de
Tue, 6 Aug 2002 21:21:28 +0200


Andreas Tille writes:
 > ... defining classes ...
 > Next I tried External Python methods but I've got strange
 > effects with this approach
Which effects. This should work (I sometimes do it), but for simple
cases, I prefer dictionaries. An alternative would be "PersistentMapping".
 > ...
 >    1. Is this the right approach to accumulate several data in the
 >       session variable even if there is a more complex menu structure
 >       of options which are sometimes dependand one from some others.
The session object is global. Thus, it is a very good idea to use
application specific namespaces to avoid name clashes.

I like subobjects for this approach also it makes life a bit more difficult
(we must explicitly tell the session that it changed when we modified
the subobject unless the subobject is persistent itself).

An alternative would be to use hierarchical keys.

 >    2. If yes what is the best way to get this working.
I usually use nested dictionaries with special precaution to
tell the session when it has changed.


Dieter