ZODB Class Template


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. from ZODB import DB
  2. from ZODB.FileStorage import FileStorage
  3. from BTrees.OOBTree import OOBTree
  4. import transaction
  5.  
  6. class erpJobStore():
  7.  
  8. def __init__(self, datapath):
  9. self.storage = FileStorage(datapath + "jobstore.fs")
  10. self.db = DB(self.storage)
  11. self.connection = self.db.open()
  12. self.dbroot = self.connection.root()
  13.  
  14. def __del__(self):
  15. self.closeConnection()
  16.  
  17. def doCommit(self):
  18. self._p_changed = 1
  19. transaction.commit()
  20.  
  21. def closeConnection(self):
  22. transaction.abort()
  23. self.db.close()
  24. self.connection.close()

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.