[Zope3-dev] Vocabularies, sources and relationships
Gary Poster
gary at zope.com
Wed Apr 6 16:48:56 EDT 2005
On Apr 6, 2005, at 4:57 AM, Santi Camps wrote:
> Hi all,
>
> I'm just beginning to study Zope 3 (helped by the magnificent Philipp
> von Weitershausen's book). I'm specially interested in the schema
> framework, and how it can be used to implement relationships between
> objects (if it can be used that way).
It can be and has been.
> I know that are proposals to replace vocabularies by sources, as
> described in the thread:
> http://mail.zope.org/pipermail/zope3-dev/2004-September/012096.html
>
> My doubs are:
> 1) Are sources already implemented ? If not, it will be ?
Basic sources are implemented. Several additional features need to be
implemented for them to be able to fully replace vocabularies. Off the
top of my head, I believe that sources now have widgets that support
searching but not iterating; vocabularies support both. Improving
sources to be a full-fledged replacement for vocabularies is an
important TODO. We are currently using sources when possible, and
using vocabularies otherwise.
> 2) In any case, are sources/vocabularies a good way to implement
> relationships between objects ?
They can certainly model them, and they are the only reasonable way to
do it in schema of which I am aware.
The storage of the relationship--the implementation--is another
decision, which we happened to just talk about around here. Standard
python references? Persistent weak references? Descriptor with an
external data source, like the schoolbell relationship tool, as a back
end? They all have pros and cons, some of them subtle.
> I think an implementation of ISource and ITerm/s and so on could be
> writted providing values obtained from other objects, but I'm not sure
> what could happen with this relationship after created. For
> instance, if the referenced object is deleted after that. Is there
> any utilities in Zope 3 to take care about referential integrity
> between objects ?
> In Zope 2, I've added some Foreign Key capabilities to Z Catalogs,
> using one catalog per meta_type and overriding manage_beforeDelete and
> so on. So, for instance, a customer can't be deleted if it has some
> referencing invoice. I just one to know if there are better ways to
> obtain the same result in Zope 3.
The best way, maybe barring the schoolbell tool, to get referential
integrity right now is probably subscribers. There are some other
frameworks in the repository to help with this--Jim mentioned
dependables--but my understanding is that they are still in an
experimental state.
Subscribers aren't perfect for this: getting a reasonable UI with
after-the-fact complaints (as most subscribers will tend to be) is
sometimes a bit tricky (another use case for ZODB save points; you can
do stuff like this in a somewhat rickety way--and I have--with
subtransactions for now), for instance. They should be workable for
many examples, though.
Gary
More information about the Zope3-dev
mailing list