Object Persistence db_save error
Take the following class. Why can't I use db_save
to store an instance of this class? The reason I am using this class instead of just a set is because I will eventually derive this class from RingElement rather than SageObject, because I'm looking to create a Ring of Sets.
class FakeSet(SageObject):
def __init__(self,_set):
self.values = _set
self.iterator = self.__iter__()
if self.values != set():
self.next = self.iterator.next()
def __iter__(self):
for this_entry in self.values:
yield this_entry
def get_set(self):
return self.values
def __repr__(self):
return str(list(self.values))
def __getattr__(self,attr):
return getattr(self.values,attr)
Then I enter:
sage: fake = FakeSet([1,2,3])
sage: print fake
sage: db_save(fake,"test")
to which the interpreter responds:
Traceback (click to the left of this block for traceback)
...
cPickle.PicklingError: Can't pickle <type 'generator'>: attribute
lookup __builtin__.generator failed