changeset 1046:3b3d4e433db3

graph can now give you the patch for a patchObject call instead of always applying it Ignore-this: 2ff7ec2361abee217bcaac9d11b0cb7
author Drew Perttula <drewp@bigasterisk.com>
date Thu, 29 May 2014 06:47:11 +0000
parents c1face79c0e1
children 16fe82c3fd71
files light9/rdfdb/grapheditapi.py
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/light9/rdfdb/grapheditapi.py	Thu May 29 06:46:18 2014 +0000
+++ b/light9/rdfdb/grapheditapi.py	Thu May 29 06:47:11 2014 +0000
@@ -11,7 +11,7 @@
     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 @@
                                      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: