Re: [SQLObject] pickling an SQLObject?
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Luke O. <lu...@me...> - 2006-06-10 00:15:23
|
I don't recall whether getstate/setstate are necessary - i think so, just for the protocol. the key is overriding new/getnewargs. i also don't recall how generally applicable this is, regarding different connection schemes etc. ## Pickle protocol hacks def __new__(cls, *args, **kw): if len(args) == 1: return cls.getByID(args[0]) return SQLObject.__new__(cls, *args, **kw) def __getnewargs__(self): return (self.id,) def __getstate__(self): return self.id def __setstate__(self, state): ''' handled by __new__/__getnewargs__ ''' pass ## End pickle protocol hacks |