Changeset - 717774b8a4a6
[Not reviewed]
default
0 1 0
Drew Perttula - 11 years ago 2014-05-28 05:55:58
drewp@bigasterisk.com
syncedgraph gets items() method for fetching an rdf list
Ignore-this: c97d4718ab1cede9c196464053c9ab47
1 file changed with 15 insertions and 1 deletions:
0 comments (0 inline, 0 general)
light9/rdfdb/autodepgraphapi.py
Show inline comments
 
@@ -99,11 +99,25 @@ class AutoDepGraphApi(object):
 
        self._watchers.addPredObjWatcher(func, predicate, object)
 
        return self._graph.subjects(predicate, object)
 

	
 
    def items(self, listUri):
 
        """generator. Having a chain of watchers on the results is not
 
        well-tested yet"""
 
        chain = set([listUri])
 
        while listUri:
 
            item = self.value(listUri, RDF.first)
 
            if item:
 
                yield item
 
            listUri = self.value(listUri, RDF.rest)
 
            if listUri in chain:
 
                raise ValueError("List contains a recursive rdf:rest reference")
 
            chain.add(listUri)
 

	
 
        
 
    def contains(self, triple):
 
        func = self._getCurrentFunc()
 
        self._watchers.addTripleWatcher(func, triple)
 
        return triple in self._graph
 
        
 

	
 
    def contextsForStatement(self, triple):
 
        """currently this needs to be in an addHandler section, but it
 
        sets no watchers so it won't actually update if the statement
0 comments (0 inline, 0 general)