SHARE
TWEET

Untitled

a guest Dec 29th, 2012 18 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from NewVariableClassZODB import *
  2. from ZODB import FileStorage, DB
  3. storage=FileStorage.FileStorage('data.fs')
  4. db=DB(storage)
  5. connection=db.open()
  6. root=connection.root()
  7. rootvar=Variable()
  8. root['EvanAI']=rootvar
  9. lipsumfile=open('lipsum.txt')
  10. lipsum=lipsumfile.read()
  11. lipsumfile.close()
  12. currentvar=rootvar
  13. for i in xrange(100):
  14.         currentvar.setvar('a',Variable(Value(lipsum)))
  15.         currentvar=currentvar.getvar('a')
  16.         connection.transaction_manager.commit()
  17. db.close()
  18.  
  19. #After loading the database:
  20. #>>>print(root['EvanAI'])
  21. #<NewVariableClassZODB.Variable object at 0x1bc88c0>
  22. #>>>print(root['EvanAI'].getvar('a'))
  23. #<NewVariableClassZODB.Variable object at 0x1bc89b0>
  24. #>>>print(root['EvanAI'].getvar('a.a')
  25. #Traceback (most recent call last):
  26. # File "<stdin>", line 2, in <module>
  27. # File "NewVariableClassZODB.py", line 44, in getvar
  28. #   return(self._getvar(path.split('.')))
  29. # File "NewVariableClassZODB.py", line 49, in _getvar
  30. #   return(self.tree[path[0]])
  31. #KeyError: 'a'
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top