[Zope-PTK] Multiple Propertysheets from the same Python class ?

Tres Seaver tseaver@digicool.com
Fri, 27 Oct 2000 08:28:05 -0400


Steinar Rune Eriksen wrote:
> 
> I am trying to make a "template"  for creating different types
> of portals.  Especially I am looking to develop my own
> DemoPortal (Portal) ZClass where I can subclass other Memberand
> PortalProperties from Python and more easily create a ZClass
> (like the Portal ZClass) that subclasses my Python classes.
> 
> Question is: Can the contents of the Portal ZClass in
> DemoPortal by fully exportet to Python code and subclassed
> inside Zope (like the ZDG describes)?

It would be quite feasible to implement a Portal derivative
entirely on the filesystem, and to make that class available as a
base class (filesystem Python can always do anything
through-the-web code does, but not vice-versa).  The
implementation details would differ, but the outward appearance
could be identical.

> I understand Python can put classes inside classes which would
> be necessary.

Not quite;  this is one of those "implementation details" which
would differ.  ZClasses are sometimes nested within other
ZClasses in order to "hide" them, as well as to make them
implicitly addable to instances of the containing ZClass.
Filesystem code doesn't need to hide things;  it merely doesn't
expose them.

> But how do you define different property sheets within one
> Python class ?

Propertysheets in a ZClass are mechanisms for organizing the
attributes of an instance or a class;  filesystem code would
typically just store and retrieve the attributes directly, and so
wouldn't "need" propertysheets.

> The DemoPortal has a MemberClass with 2 propertysheets
> (CommonProperties and SystemProperties) which I guess must be
> kept separate.

They are separated in order to allow/require separate calls to
'manage_changeProperties' from DTML;  filesystem code has more
freedom, and could  implement two separate "property setting"
methods to accomplish the same goal.  
> Is this at all possible to do from Python, or am I barking up
> the wrong tree here.

It is possible (and maybe even desirable!)  We have actually
discussed the idea here.

Tres.
--
===============================================================
Tres Seaver                                tseaver@digicool.com
Digital Creations     "Zope Dealers"       http://www.zope.org