2008-10-31 25 views
5

我目前正在瀏覽Redland的Python綁定,並且還沒有找到一種乾淨的方式來通過它在存儲引擎上執行事務。我在低級Redland模塊中發現了一些模型事務:Redland的Python綁定中的存儲事務?

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) 

這些是否也轉譯爲存儲層?

謝謝:-)

回答

4

是的,這應該工作。目前python包裝中的模型類沒有任何便利功能,但它們與您寫的類似:

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