[Zope-dev] Objects with multiple parents and storage flexibility, ZPatterns?

Steve Spicklemire steve@spvi.com
Wed, 3 Jan 2001 12:47:05 -0500 (EST)


Hi Chris,

Random thoughts follow. ;-)

   I think that if you make your DataSkins folderish it will be hard
to make the storage anything other than ZODB.  However, Steve
Alexander posted a neat trick the other day where __bobo_traverse__ is
supplied by an attribute provider. You could use this to make your
DataSkins traversable. Let's say your objects have an attribute that
defines them in the context of their parent (e.g., dataskin2 in your
example URL), let's call it 'context_id'. You may have six objects
with the same context_id, but they would all have different parents.
Now.. you could implement a search interface that finds an object
in context.  

GetObjectInContextOfParent( context_id, parent_id )

Each object must also (of course) have a parent_id, unless it's
a root level object. In SQL this might be:

select * from objectXs where parent_id = 'dataskin1_id' and context_id = 'dataskin2'

or it could be a catlog search, if you're in ZODB. 


Now for the traversal interface:

    def __bobo_traverse__(self, REQUEST, name):
        ob = getattr(self, name, _marker)
        if ob is _marker:
            ob = self.GetObjectInContextOfParent( context_id = name, parent_id = self.id)
            if ob is not None:
                return ob
            raise 'NotFound'
        return ob

Totally untested of course. ;-) Anyway the idea would be to *not* use folderish
DataSkins, but to build a hierarchy out of them that could be traversed.

-steve