[Zope-dev] RFC: RelationAware class for relations between objects

Gary Poster gary@ZOPE.COM
Mon, 28 Apr 2003 13:44:48 -0400


roche@upfrontsystems.co.za wrote:
> * Shane Hathaway <shane@zope.com> [2003-04-28 17:09]: 
> I also think relations shouldn't require Zope and Jeremy sure shows that
> it can be done in pure python. What I appreciate about this is that it
> might provide a solution that might be workable with Zope 2 in the
> interim and Zope 3 later on.

If we could make this work with Zope 2 and 3 context wrapping 
somehow--i.e., be able to get a related object in context--then this 
would be the relationship tool that we need.  Unless we can do that, I 
only see this model applicable in Zope if we are using a repository-type 
system--not the standard pattern.

...

> I have one requirement though and that is that it should work with Zope
> 2 (not require it). Zope 2 apps are my bread and butter at the moment
> but for now I am going to assume that Zope 2 works fine with python 2.2
> and that a descriptor based solution is the way to go.

I don't think objects with these descriptors can be stored in ZODB 3, 
though.  Right now this is a Zope 3-only (ZODB 4-only) prospect, AFAIK. 
   If anybody can shoot that down, it's Jeremy, though. ;-)

>>The current Zope 3 plan is to put all relation management in a service. 
>> As I see it, that is one possible implementation of Jeremy's 
>>relation() function.  Also, I would be a little disappointed if creating 
>>relations always required writing XML-based configuration documents or 
>>visiting something in the management interface.  Instead, a little bit 
>>of Python code ought to be sufficient.

I agree that having something easy to use is very attractive.  :-)  I 
don't know if we're on the same page as far as creating relation types: 
I think setting up the possibility, say, of an "authored" relation 
between IBook and IContact should be an explicit configuration 
step--somewhere, maybe in code but maybe not--that enforces the fact 
that doing so is a non-trivial operation, data-wise.  *Using* that 
relation should be trivial and easy.

But if Jeremy just does what he wants and it works well enough for what 
we need, hey, I'm happy.

Gary