Commits

Anonymous committed 9334d42

push some transaction handling up the stack in the handler

  • Participants
  • Parent commits 7998369

Comments (0)

Files changed (2)

File ordf/handler/__init__.py

         if embedded_changeset or cs:
             self.handler.put(self.store)
 
+        self.handler.commit()
+        
         return cs
 
     def rollback(self):
         This simply emptying it of graphs that have been previously added using
         :meth:`add`.
         """
+        self.handler.rollback()
+        
         dummy = Graph("IOMemory")
         self.store = dummy.store
 
         for h in self.__readers__:
             h.remove(*av, **kw)
 
+    def commit(self, *av, **kw):
+        for h in self.__writers__:
+            h.commit()
+
+    def rollback(self, *av, **kw):
+        for h in self.__writers__:
+            h.rollback()
+            
     def context(self, user, reason):
         """
         Return an instance of :class:ChangeContext bound to this
         if hasattr(self, "fourstore"):
             return self.fourstore.query(q, initNs=namespaces)
         elif hasattr(self, "rdflib"):
-            prefixes = ["PREFIX %s: <%s>" % (k, namespaces[k]) for k in namespaces]
-            q = "\n".join(prefixes) + "\n" + q
+            #prefixes = ["PREFIX %s: <%s>" % (k, namespaces[k]) for k in namespaces]
+            #q = "\n".join(prefixes) + "\n" + q
             return self.rdflib.query(q)
         else:
             raise AttributeError("No SPARQL Implementations")
 
+        
 class HandlerPlugin(object):
     """
     Instances of this class implement read and/or write operations on storage
         Implement in concrete subclasses
         """
 
+    def commit(self):
+        """
+        Impement in concrete subclasses
+        """
+
+    def rollback(self):
+        """
+        Implement in concrete subclasses
+        """
+        
 class ConfigError(Exception):
     """
     Raised on configuration error

File ordf/handler/rdf.py

         orig = Graph(self.store, identifier=ident)
         new = Graph(identifier=ident)
         new += orig
-        orig.rollback()
         return new
     def __setitem__(self, k, g):
         assert isinstance(g, _Graph)
         old.remove((None, None, None))
         for statement in g.triples((None, None, None)):
             old.add(statement)
-        old.commit()
         if hasattr(self.store, "sync"):
             self.store.sync()
     def __delitem__(self, k):
         old = Graph(self.store, identifier=get_identifier(k))
         old.remove((None, None, None))
-        old.commit()
         if hasattr(self.store, "sync"):
             self.store.sync()
 
     def append(self, g):
         old = Graph(self.store, identifier=g.identifier)
         old += g
-        old.commit()
         if hasattr(self.store, "sync"):
             self.store.sync()
                                     
             g = ConjunctiveGraph(self.store)
             return g.query(*av, **kw)
 
+    def commit(self):
+        self.store.commit()
+    def rollback(self):
+        self.store.rollback()
+        
 class FourStore(RDFLib):
     """
     Use of this back-end requires the `py4s`_ bindings to `4store`_.