# HG changeset patch # User Drew Perttula # Date 2014-05-29 06:47:11 # Node ID 3b3d4e433db3148b7be489dd1d8c4f66e1fd11b2 # Parent c1face79c0e1dacfeded982f71638931d8216aba graph can now give you the patch for a patchObject call instead of always applying it Ignore-this: 2ff7ec2361abee217bcaac9d11b0cb7 diff --git a/light9/rdfdb/grapheditapi.py b/light9/rdfdb/grapheditapi.py --- a/light9/rdfdb/grapheditapi.py +++ b/light9/rdfdb/grapheditapi.py @@ -11,7 +11,7 @@ class GraphEditApi(object): mixin for SyncedGraph, separated here because these methods work together """ - def patchObject(self, context, subject, predicate, newObject): + def getObjectPatch(self, context, subject, predicate, newObject): """send a patch which removes existing values for (s,p,*,c) and adds (s,p,newObject,c). Values in other graphs are not affected. @@ -23,13 +23,16 @@ class GraphEditApi(object): context=context): existing.append(spo+(context,)) # what layer is supposed to cull out no-op changes? - p = Patch( + return Patch( delQuads=existing, addQuads=([(subject, predicate, newObject, context)] if newObject is not None else [])) + + def patchObject(self, context, subject, predicate, newObject): + p = self.getObjectPatch(context, subject, predicate, newObject) log.info("patchObject %r" % p.jsonRepr) self.patch(p) - + def patchMapping(self, context, subject, predicate, nodeClass, keyPred, valuePred, newKey, newValue): """ creates/updates a structure like this: