[Zope3-dev] Interfaces and Schemas

Martijn Faassen faassen at vet.uu.nl
Mon Aug 11 00:00:04 EDT 2003


Steve Waterbury wrote:
> Basically, I see schemas and interfaces as complementary, and
> perhaps "equal" in a sense.

In Zope 3, schemas are just normal interfaces with some fields defined
by them. So basically schemas are just interfaces.

> The idea I'd like to propose is
> that an interface could have a schema associated with it, and
> that they could be similarly named -- e.g., an IDocument and
> an SDocument.  And there should probably be well-defined
> (i.e. testable) relationships between the methods of IDocument
> and their effects on the "fields" (which in some cases may be
> state-dependent) of SDocument.  And each could have families
> of Adapters, which in general would be quite different.
> 
> Any class then could implement either the interface or the
> schema (or both, or neither), but presumably there would at
> least be a Document class that implements both.
> 
> Is that concept compatible with Zope 3's architecture?

In Zope 3, you'd typically just add the schema's field to the
interface itself, so that the relationship between the fields
and methods is obvious. 

You could however do something like you propose by separating out
the method related interface from the schema related interface. I
don't see why you'd do that, though. If as you say the relationship
between the methods and the fields exists, why not put them in the
same interface? Why make it possible for a class to implement the
methods but not the fields, or vica versa?

> (From what I've read so far, it isn't quite compatible, but
> might be doable.)
> 
> Perhaps more importantly, is it of interest at all?

I'm not quite clear on what exactly it is that you are proposing here.

> (It is of direct use in my application because I have an O-R
> mapping to a PostgreSQL backend, and schemas and interfaces will
> all be persistent in the registry that drives the mapping, so I
> will implement something like this one way or another. :^)

Doing O-R style stuff with Zope 3 schemas *would* of course be
interesting. :)

Regards,

Martijn




More information about the Zope3-dev mailing list