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?



Zope-Dev maillist  -  Zope-Dev@zope.org
**  No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope )

Reply via email to