[Zope3-dev] schema initial documentation

Phillip J. Eby pje@telecommunity.com
Sat, 20 Apr 2002 13:13:03 -0500


At 01:26 AM 4/20/02 +0200, Martijn Faassen wrote:

>     Enough theory; how does one define a schema? Much like one would
>     define an interface, but it has fields instead of methods::
>
>       from Interface import Schema
>
>       class IPerson(Schema):
>           """A simple schema for a person.
>           """
>
>           initials = StringField(
>              title="Initials",
>              description="Initials.",
>              )

Why have a separate base for Schema?  Interfaces already support Attribute 
objects, let's just make fields derive from Attribute or something similar.

One thing that's rather interesting here; an opportunity for overlap with 
Features in TransWarp...

In TransWarp, a "feature" is a class attribute that can export methods to 
its containing class, possibly in addition to being a property of that 
class' instances.  For example, if a class "Person" has a "limbs" feature, 
that feature might export "addLimb()" and "removeLimb()" methods to Person 
instances.  The presence, name, and semantics of these methods are all 
implied by the feature type and the name of the feature.

This concept is drawn directly from the notion of a Feature in CORBA's MOF 
(meta-object facility), and thus maps nicely to CORBA and other IDL's.  It 
would be nice if there were a way to represent this in Zope 
Interfaces.  That is, to specify a notion such as a feature and allow it to 
imply the presence of other methods, etc.

If the constructor for Interface objects walked through its contained 
definitions and "asked them" to "install yourself in me", this would allow 
the definition of patterned features such as used by TransWarp, CORBA, 
JavaBeans, and various IDL systems such as COM.