Advertisement
Guest User

Untitled

a guest
Dec 15th, 2016
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. f = open('my.pickle', 'ab')
  2.  
  3. class ID(object):
  4. def __init__(self, entity):
  5. self.entity_class = entity.__class__
  6. self.entity = entity
  7. objects[ID].append(self)
  8. if self.entity_class not in objects.keys():
  9. objects[self.entity_class] = []
  10. objects[self.entity_class].append(self.entity)
  11. else:
  12. objects[self.entity_class].append(self.entity)
  13.  
  14. objects = {ID:[]}
  15.  
  16. class Entity():
  17. fields_preset = []
  18. relations_preset = []
  19. def __init__(self):
  20. self.entity_id = ID(self)
  21. self.fields = []
  22. self.relations = []
  23.  
  24. t =type("NewType", (Entity,), {"x": "hello"})
  25. t()
  26. pickle.dump(objects, f, 2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement