[Zope-dev] References, persistence, BTrees

Jeffrey P Shell jeffrey@cuemedia.com
Thu, 3 Jan 2002 17:49:09 -0700


I'm experimenting with an event notification service based on a 
publish-subscribe model for some projects I'm working on.  When a 
subscription comes in, a 'Subscription' object is made, that 
basically looks like this:

class Subscription(Base):
     def __init__(self, subscriber, eventType, filter=None):
         self.subscriber = subscriber
         self.eventType = eventType
         self.filter = filter

     def __hash__(self):
         return hash(self.subscriber) & \
                hash(self.eventType) & \
                hash(self.filter)

'subscriber' is a reference to the subscribing object, and it's 
very likely to be to an object in the ZODB.  Is it wise to have 
more than one persistent reference to a single persistent object?  
I swear that I had once heard Jim say (vocally) that you could do 
references like this in the ZODB now.  I'm trying to avoid using 
Paths because objects have a tendency to move around[*], and I have 
performance concerns for a single event service object to have to 
call 'unrestrictedTraverse' to every subscriber.

[*] (it's due to the annoyances with manage_beforeDelete() and 
friends that
I'm writing this tool.)

Second question: If I use the hash of the Subscription as a key, is 
there any advantages/disadvantages with using an IOBTree to hold 
Subscription objects instead of a PersistentMapping?

Jeffrey P Shell, jeffrey@cuemedia.com