[Zope-dev] Zope.schema extension with marker interface

Jan Van Hees jakkevanhees at gmail.com
Fri Jun 7 06:45:23 UTC 2013


Hi

 

A bit of context first:

We have a zope application, using zope.schema to define our objects. The
problem is, we have circular references, units contain references to persons
and persons contain references to units.

For schema validation, this is solved by subclassing zope.schema.Object and
making it aware of reference objects and contained objects. So far so good.

 

Now I'm working on z3c.schema2json (originally by Paul Wilson), allowing
zope.schema defined objects to be converted to a dictionary structure. The
problem I encounter here is that there is no awareness of reference or
containment. This causes endless recursion going from person to unit back to
person back to unit, . .

 

A clean way to solve this, would be adding a marker interface
IReference/ILazyLoad, . ., to the reference objects. If the serializer
encounters the IReference interface, it can be skipped for serialization.
The same concept could probably be used for the schema validation.

 

To me the best place to add this marker interface is in
zope.shema.interfaces, because it's actually working on zope.schema. I'm
happy to fork zope.schema on github and make it working, but I'd like your
feedback on this, before I start working on it. 

 

Pro's, con's? Scenarios I miss?

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.zope.org/pipermail/zope-dev/attachments/20130607/27d7ebb8/attachment.html>


More information about the Zope-Dev mailing list