[Zope3-dev] zwiki: performance of findChildren()
Roché Compaan
roche@upfrontsystems.co.za
Fri, 25 Apr 2003 20:51:29 +0200
* Jeremy Hylton <jeremy@zope.com> [2003-04-25 19:50]:
> I'd like to understand it better too. I think the idea is to represent
> relations between two objects using a BTree index with properties on the
> object themselves to keep a natural Python API. Here's an example I've
> invented to have something concrete to talk about.
>
> class SoftwareProject(Persistent):
>
> def __init__(self, name):
> self.name = name
> self.developers = rel
>
> class Developer(Persistent):
>
> def __init__(self):
> self.name = name
> self.projects = rel
>
> rel = relation(Developers, SoftwareProject)
>
> zope3 = SoftwareProject("Zope3")
> jim = Developer("Jim Fulton")
> stevea = Developer("Steve Alexander")
>
> zope.developers.add(jim)
> zope.developers.add(stevea)
> assert zope in stevea.projects
>
> One idea is that if the relation is populated in one direction, it is
> also manifest in the other direction. I think this means that the
> system is reponsible for providing referential integrity.
>
I think the cardinality of the relationship is important too. If it is
a many to many relationship like the above then one would know that
zope3.developers and stevea.projects would both return sequences. But if
I register the relationship between SoftwareProject and Developer as a
many to one relationship:
rel = relation(SoftwareProject, Developer, OneToMany)
then the following will hold true:
assert zope3.developer.Name == 'Steve Alexander'
as well as:
assert zope3 in steva.projects
--
Roché Compaan
Upfront Systems http://www.upfrontsystems.co.za