Changeset - 3b3d4e433db3
[Not reviewed]
default
0 1 0
Drew Perttula - 11 years ago 2014-05-29 06:47:11
drewp@bigasterisk.com
graph can now give you the patch for a patchObject call instead of always applying it
Ignore-this: 2ff7ec2361abee217bcaac9d11b0cb7
1 file changed with 6 insertions and 3 deletions:
0 comments (0 inline, 0 general)
light9/rdfdb/grapheditapi.py
Show inline comments
 
@@ -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:
0 comments (0 inline, 0 general)