Mercurial > code > home > repos > light9
changeset 1042:717774b8a4a6
syncedgraph gets items() method for fetching an rdf list
Ignore-this: c97d4718ab1cede9c196464053c9ab47
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Wed, 28 May 2014 05:55:58 +0000 |
parents | a4632a7b2e17 |
children | aa45e5379c5a |
files | light9/rdfdb/autodepgraphapi.py |
diffstat | 1 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/rdfdb/autodepgraphapi.py Wed May 28 05:54:23 2014 +0000 +++ b/light9/rdfdb/autodepgraphapi.py Wed May 28 05:55:58 2014 +0000 @@ -99,11 +99,25 @@ 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