SHARE
TWEET

Untitled

a guest Dec 29th, 2012 17 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. #<NewVariableClassZODB.Variable object at 0x1bc8aa0>
  26. #>>>print(root['EvanAI'].getvar('a.a.a.a.a.a.a.a.a')
  27. #<NewVariableClassZODB.Variable object at 0x1bcf488>
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