Oleg Broytmann wrote:
On Mon, Jun 12, 2006 at 11:50:49AM +0200, sophana wrote:
  
class MySqlObject(SQLObject):
   def __getstate__(self):
       return self.id
   def __setstate__(self,id):
       pass
   def __new__(cls, *args, **kw):
       if len(args) == 1:
           return cls.get(args[0])
       return SQLObject.__new__(cls, *args, **kw)

   def __getnewargs__(self):
       return (self.id,)
    

   I think it'd be a good idea to add this to SQLObject. Ian?

Oleg.
  
Just a remark: as I said, this method does not work for the default pickle protocol 0.
It would be nice to have a method that works in all protocols based on getstate - setstate only.
But I don't think it is possible.
There should not be multiple instances of the same row.
The problem with setstate is that the object instance is already created with a new id, and cannot be replaced by the already exeisting instance os the cache.

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

Reply via email to