Mercurial > code > home > repos > light9
changeset 1267:ce8a71fab284
trying to fix SC bad graph reload behavior, but this barely works. other tools have trouble too
Ignore-this: 862de28b7f1eba9794ec766c22e8d9be
author | drewp@bigasterisk.com |
---|---|
date | Sun, 14 Jun 2015 03:30:34 +0000 |
parents | 1b6583740f76 |
children | 7213af750481 |
files | bin/subcomposer |
diffstat | 1 files changed, 20 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/bin/subcomposer Sun Jun 14 03:30:01 2015 +0000 +++ b/bin/subcomposer Sun Jun 14 03:30:34 2015 +0000 @@ -72,6 +72,8 @@ tk.Frame.__init__(self, master, bg='black') self.graph = graph self.session = session + self.launchTime = time.time() + self.localSerial = 0 # this is a URIRef or Local. Strangely, the Local case still # has a uri, which you can get from @@ -158,13 +160,20 @@ @graph.addHandler def graphChanged(): + # some bug where SC is making tons of graph edits and many + # are failing. this calms things down. + log.warn('skip graphChanged') + return + s = graph.value(self.session, L9['currentSub']) + log.debug('HANDLER getting session currentSub from graph: %s', s) if s is None: s = self.switchToLocal() self.currentSub(Submaster.PersistentSubmaster(graph, s)) @self.currentSub.subscribe def subChanged(newSub): + log.debug('HANDLER currentSub changed to %s', newSub) if newSub is None: graph.patchObject(self.session, self.session, L9['currentSub'], None) @@ -176,21 +185,25 @@ localStmt = (newSub.uri, RDF.type, L9['LocalSubmaster']) with graph.currentState(tripleFilter=localStmt) as current: if newSub and localStmt in current: + log.debug(' HANDLER set _currentChoice to Local') self._currentChoice(Local) else: # i think right here is the point that the last local - # becomes garbage, and we could clean it up. + # becomes garbage, and we could clean it up. + log.debug(' HANDLER set _currentChoice to newSub.uri') self._currentChoice(newSub.uri) dispatcher.connect(self.levelsChanged, "sub levels changed") @self._currentChoice.subscribe def choiceChanged(newChoice): + log.debug('HANDLER choiceChanged to %s', newChoice) if newChoice is Local: newChoice = self.switchToLocal() if newChoice is not None: - self.currentSub(Submaster.PersistentSubmaster( - graph, newChoice)) + newSub = Submaster.PersistentSubmaster(graph, newChoice) + log.debug('write new choice to currentSub, from %r to %r', self.currentSub(), newSub) + self.currentSub(newSub) def levelsChanged(self, sub): if sub == self.currentSub(): @@ -202,8 +215,10 @@ """ # todo: where will these get stored, or are they local to this # subcomposer process and don't use PersistentSubmaster at all? - - new = URIRef("http://light9.bigasterisk.com/sub/local/%s" % time.time()) + localId = "%s-%s" % (self.launchTime, self.localSerial) + self.localSerial += 1 + new = URIRef("http://light9.bigasterisk.com/sub/local/%s" % localId) + log.debug('making up a local sub %s', new) self.graph.patch(Patch(addQuads=[ (new, RDF.type, L9['Submaster'], self.session), (new, RDF.type, L9['LocalSubmaster'], self.session),