diff --git a/bin/effecteval b/bin/effecteval --- a/bin/effecteval +++ b/bin/effecteval @@ -68,6 +68,7 @@ class SongEffects(PrettyErrorHandler, cy p = yield songEffectPatch(self.settings.graph, dropped, song, event, ctx=song) self.settings.graph.patch(p) + self.settings.graph.suggestPrefixes({'song': URIRef(song + '/')}) class SongEffectsUpdates(cyclone.websocket.WebSocketHandler): def connectionMade(self, *args, **kwargs): diff --git a/bin/rdfdb b/bin/rdfdb --- a/bin/rdfdb +++ b/bin/rdfdb @@ -180,9 +180,10 @@ class WatchedFiles(object): This object watches directories. Each GraphFile watches its own file. """ - def __init__(self, dirUriMap, patch, getSubgraph): + def __init__(self, dirUriMap, patch, getSubgraph, addlPrefixes=None): self.dirUriMap = dirUriMap # {abspath : uri prefix} self.patch, self.getSubgraph = patch, getSubgraph + self.addlPrefixes = addlPrefixes self.graphFiles = {} # context uri : GraphFile @@ -239,7 +240,8 @@ class WatchedFiles(object): ctx = uriFromFile(self.dirUriMap, inFile) gf = GraphFile(self.notifier, inFile, ctx, - self.patch, self.getSubgraph) + self.patch, self.getSubgraph, + addlPrefixes=self.addlPrefixes) self.graphFiles[ctx] = gf log.info("%s do initial read", inFile) gf.reread() @@ -262,7 +264,8 @@ class WatchedFiles(object): assert '//' not in outFile, (outFile, self.dirUriMap, ctx) log.info("starting new file %r", outFile) self.graphFiles[ctx] = GraphFile(self.notifier, outFile, ctx, - self.patch, self.getSubgraph) + self.patch, self.getSubgraph, + addlPrefixes=self.addlPrefixes) def dirtyFiles(self, ctxs): """mark dirty the files that we watch in these contexts. @@ -282,13 +285,13 @@ class Db(object): """ the master graph, all the connected clients, all the files we're watching """ - def __init__(self, dirUriMap): + def __init__(self, dirUriMap, addlPrefixes=None): self.clients = [] self.graph = ConjunctiveGraph() self.watchedFiles = WatchedFiles(dirUriMap, - self.patch, self.getSubgraph) + self.patch, self.getSubgraph, addlPrefixes) self.summarizeToLog() @@ -466,7 +469,8 @@ if __name__ == "__main__": log.setLevel(logging.DEBUG if options.verbose else logging.INFO) db = Db(dirUriMap={os.environ['LIGHT9_SHOW'].rstrip('/') + '/': - showconfig.showUri() + '/'}) + showconfig.showUri() + '/'}, + addlPrefixes={'show': URIRef(showconfig.showUri() + '/')}) from twisted.python import log as twlog twlog.startLogging(sys.stdout) diff --git a/light9/rdfdb/graphfile.py b/light9/rdfdb/graphfile.py --- a/light9/rdfdb/graphfile.py +++ b/light9/rdfdb/graphfile.py @@ -63,7 +63,7 @@ class GraphFile(object): """ one rdf file that we read from, write to, and notice external changes to """ - def __init__(self, notifier, path, uri, patch, getSubgraph): + def __init__(self, notifier, path, uri, patch, getSubgraph, addlPrefixes=None): """ uri is the context for the triples in this file. We assume sometimes that we're the only ones with triples in this @@ -84,6 +84,8 @@ class GraphFile(object): 'effect': 'http://light9.bigasterisk.com/effect/', 'dev': 'http://light9.bigasterisk.com/device/', } + if addlPrefixes: + self.namespaces.update(addlPrefixes) if not os.path.exists(path): # can't start notify until file exists diff --git a/light9/rdfdb/syncedgraph.py b/light9/rdfdb/syncedgraph.py --- a/light9/rdfdb/syncedgraph.py +++ b/light9/rdfdb/syncedgraph.py @@ -126,7 +126,6 @@ class SyncedGraph(CurrentStateGraphApi, log.debug('patch is done %s', debugKey) def suggestPrefixes(self, prefixes): - song note edit should put song: to the song uri self.addlPrefixes.update(prefixes) def sendFailed(self, result):