def sourceAdded(self, catalog): queries = set() for token in catalog.getRelationTokens(): additions = dict( (info['name'], catalog.getValueTokens(info['name'], token)) for info in catalog.iterValueIndexInfo()) queries.update( tuple(q.items()) for q in self.getQueries(token, catalog, additions, {}, False)) for q in queries: self._indexQuery(q)
def sourceRemoved(self, catalog): # this only really makes sense if the getQueries/getValueTokens was # changed queries = set() for token in catalog.getRelationTokens(): removals = dict( (info['name'], catalog.getValueTokens(info['name'], token)) for info in catalog.iterValueIndexInfo()) queries.update( tuple(q.items()) for q in self.getQueries(token, catalog, {}, removals, True)) for q in queries: self._indexQuery(q)
def getQueries(relchain): if not relchain: yield query return if other is None: rels = relchain[-1] else: tokens = catalog.getValueTokens(other, relchain[-1]) if not tokens: return rels = zc.relation.catalog.Any(tokens) res = BTrees.family32.OO.Bucket(static) res[name] = rels yield res