def connect_to(self, location, uri=None): uri = uri or location storeIO = TripleStoreIO() storeIO.load(location, uri, 0) self.neighbours.add_store(storeIO) self.remove(resource(location), TYPE, NEIGHBOUR) self.add(resource(location), TYPE, NEIGHBOUR) self.remove(resource(location), CONNECTED, None) self.add(resource(location), CONNECTED, YES)
def __init__(self): TripleStoreIO.__init__(self) self.dirtyBit = DirtyBit()
def load(self, location, uri=None, create=0): TripleStoreIO.load(self, location, uri, create) print "Done loading '%s'" % location self.dirtyBit.clear() # we just loaded... therefore we are clean self._start_thread()
def add(self, subject, predicate, object): self.dirtyBit.set() TripleStoreIO.add(self, subject, predicate, object)
def remove(self, subject=None, predicate=None, object=None): self.dirtyBit.set() TripleStoreIO.remove(self, subject, predicate, object)
def visit(self, callback, triple): for store in self.stores: stop = store.visit(callback, triple) if stop: return stop # TODO this belongs elsewhere (make generic first) def to_relative_URL(path): import sys from os.path import join, dirname from urllib import pathname2url libDir = dirname(sys.modules["redfoot.rednode"].__file__) return pathname2url(join(libDir, path)) schema = TripleStoreIO() schema.load(to_relative_URL("rdf_files/rdfSchema.rdf"), "http://www.w3.org/2000/01/rdf-schema") syntax = TripleStoreIO() syntax.load(to_relative_URL("rdf_files/rdfSyntax.rdf"), "http://www.w3.org/1999/02/22-rdf-syntax-ns") builtin = TripleStoreIO() builtin.load(to_relative_URL("rdf_files/builtin.rdf"), "http://redfoot.sourceforge.net/2000/10/06/builtin") class RedNode(SchemaQuery): def __init__(self, uri, autosave=1): self.uri = uri if autosave: self.local = AutoSaveLocal() # local only else: