# HG changeset patch # User Drew Perttula # Date 1370679759 0 # Node ID 3b1a435a29b818bd774483ba00772952d8e81d15 # Parent cad8207933d73df9cb40f17b6d1cd7a70c202070 start fixing curvecalc data model; not done yet Ignore-this: 9960bef2556cd57da749e921bcf3248 diff -r cad8207933d7 -r 3b1a435a29b8 bin/curvecalc --- a/bin/curvecalc Sat Jun 08 08:21:24 2013 +0000 +++ b/bin/curvecalc Sat Jun 08 08:22:39 2013 +0000 @@ -35,6 +35,7 @@ from light9.curvecalc.output import Output from light9.gtkpyconsole import togglePyConsole from light9.rdfdb.syncedgraph import SyncedGraph +from light9.rdfdb.patch import Patch from light9.editchoicegtk import EditChoice from light9.observable import Observable @@ -157,13 +158,26 @@ self.makeSubterm(newname, withCurve=wc) dialog.hide() + def currentSong(self): + with self.graph.currentState() as current: + return current.value(self.session, L9['currentSong']) + + def songSubtermsContext(self): + return self.currentSong() + def makeSubterm(self, newname, withCurve=False, expr=None): uri = L9['sub/%s' % newname] - if (uri, RDF.type, L9.Subterm) in self.graph: - raise SubtermExists("already have a subterm named %r" % newname) - self.graph.add((uri, RDF.type, L9.Subterm)) - self.graph.add((uri, RDFS.label, Literal(newname))) - self.graph.add((self.song, L9['subterm'], uri)) + with self.graph.currentState() as current: + if (uri, RDF.type, L9.Subterm) in current: + raise SubtermExists("already have a subterm named %r" % newname) + + ctx = self.songSubtermsContext() + self.graph.patch(Patch(addQuads=[ + (uri, RDF.type, L9.Subterm, ctx), + (uri, RDFS.label, Literal(newname), ctx), + (self.currentSong(), L9['subterm'], uri, ctx), + ])) + if withCurve: self.curveset.new_curve(newname) diff -r cad8207933d7 -r 3b1a435a29b8 doc/subterms --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/subterms Sat Jun 08 08:22:39 2013 +0000 @@ -0,0 +1,8 @@ + + +song + -- :subterm --> + st + -- rdfs:label --> "chase 1" + -- :sub --> sub + -- :expression --> "curve1(t)" \ No newline at end of file diff -r cad8207933d7 -r 3b1a435a29b8 light9/curvecalc/subtermview.py --- a/light9/curvecalc/subtermview.py Sat Jun 08 08:21:24 2013 +0000 +++ b/light9/curvecalc/subtermview.py Sat Jun 08 08:22:39 2013 +0000 @@ -1,6 +1,6 @@ import gtk, logging from louie import dispatcher -from rdflib import RDF, RDFS, Literal +from rdflib import URIRef from light9 import Submaster from light9.namespaces import L9 from light9.curvecalc.subterm import Subterm, Subexpr @@ -58,6 +58,7 @@ self.exprView = sev.box def add_one_subterm(graph, subUri, curveset, subterms, master, expr=None, show=False): + assert isinstance(subUri, URIRef), subUri subname = graph.label(subUri) log.info("%s's label is %s" % (subUri, subname)) if not subname: # fake sub, like for a chase