views:

112

answers:

1

I've currently skimming through the Python-bindings for Redland and haven't found a clean way to do transactions on the storage engine via it. I found some model-transactions within the low-level Redland module:

import RDF, Redland

storage = RDF.Storage(...)
model = RDF.Model(storage)
Redland.librdf_model_transaction_start(model._model)
try:
    # Do something
    Redland.librdf_model_transaction_commit(model._model)
    model.sync()
except:
    Redland.librdf_model_transaction_rollback(model._model)

Do these also translate down to the storage layer?

Thanks :-)

+2  A: 

Yes, this should work. There are no convenience functions for the model class in the python wrapper right now but they would be similar to what you wrote:

class Model(object):
  ...
  def transaction_start(self):
    return Redland.librdf_model_transaction_start(self._model)
dajobe