I'm trying to build a Reverse Cross Referencing Product. The idea is to
enable documents to know which other documents in the Zope data base are
pointing at them.
I would like to use a persistent mapping to store the link information,
but since eventually the object might be quite large will I get a
performance hit when accessing only a small part of the object.

It certainly seems to work for small instances, but I'm worried about
what happens as my structure gets larger. Is there an alternate way to
do this?


The heart of the object are the methods

 
        def __init__(self, id, title):
                '''Initialise a new instance of RXRef'''
                self.id=str(id)
                self.title = str(title)
                self.title = title
                self._N = PersistentMapping()

        def addNode(self,n):
                '''Add a new node if not known'''
                N = self._N
                if not N.has_key(n): N[n]=[]

        def addLinks(self,src,DST):
                '''We have a single src and multiple destinations'''
                if type(DST) not in SEQTYPES: DST = [DST]
                N = self._N
                for dst in DST:
                        self.addNode(dst)
                        if src not in N[dst]: N[dst].append(src)

        def delLinks(self,src,DST):
                '''We have a single src and multiple destinations'''
                if type(DST) not in SEQTYPES: DST = [DST]
                N = self._N
                for dst in DST:
                        if N.has_key(dst):
                                if src in N[dst]:
                                        N[dst].remove(src)
                                        if N[dst]==[]: del N[dst]

        def getRLinks(self,dst):
                '''get links pointing to dst'''
                N = self._N
                return N.has_key(dst) and N[dst][:] or []

-- 
Robin Becker

_______________________________________________
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to