[Zope] zope.schema: association vs. containment in Object, List

Sean Upton sdupton at gmail.com
Fri Jun 6 04:54:02 EDT 2008


All,

I want to be able to spell out certain zope.schema.Object fields in my
interfaces as "contained" while other fields are declared as
associated/related objects.  I'm interested in describing this in the
interface itself, and not leave such intrinsic characteristics to the
implementation class.  It is useful, in my experience to have the
ability for utility components to know this about a field (for
example, relational database deletion cascades, JSON serialization of
an object and its contained objects, neglecting related objects, or
you might end up serializing the entire graph).

Are there any community best practices for doing this?

My previous attempts at doing this have been to subclass List and
Object for OneToMany and OneToOne field types respectively, and treat
original Object and List(value_type=Object()) fields as always
implying containment.  Is this reasonable?  Are there other or better
approaches?

Thanks,
Sean


More information about the Zope mailing list