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




_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to