]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
adjusted __getstate__ on InstrumentedList to further avoid callables getting stuck...
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 8 Aug 2006 01:02:16 +0000 (01:02 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 8 Aug 2006 01:02:16 +0000 (01:02 +0000)
CHANGES
lib/sqlalchemy/attributes.py
test/base/attributes.py

diff --git a/CHANGES b/CHANGES
index 83ea698d8336a1b48c7710225295c58d8087ab07..5dd60be3a3dfd85331f8c8035f4344e572a1b5ea 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -22,7 +22,7 @@ succeeded.  added a test script to attempt testing this.
 - SingletonThreadPool has a size and does a cleanup pass, so that 
 only a given number of thread-local connections stay around (needed
 for sqlite applications that dispose of threads en masse)
-- fixed small pickle bug with lazy loaders [ticket:265]
+- fixed small pickle bug(s) with lazy loaders [ticket:265] [ticket:267]
 - fixed possible error in mysql reflection where certain versions
 return an array instead of string for SHOW CREATE TABLE call
 
index 1c4f07ac6c3c2fc33846ca06b2ec01116ccf21be..c709afe3dc67cf8207557f9c6c2fbaafc605ed0c 100644 (file)
@@ -300,14 +300,16 @@ class InstrumentedList(object):
         self[:] = []
         
     def __getstate__(self):
-        """implemented to allow pickling, since __obj is a weakref."""
-        return {'key':self.key, 'obj':self.obj, 'data':self.data, 'attr':self.attr}
+        """implemented to allow pickling, since __obj is a weakref, also the InstrumentedAttribute has callables
+        attached to it"""
+        return {'key':self.key, 'obj':self.obj, 'data':self.data}
     def __setstate__(self, d):
-        """implemented to allow pickling, since __obj is a weakref."""
+        """implemented to allow pickling, since __obj is a weakref, also the InstrumentedAttribute has callables
+        attached to it"""
         self.key = d['key']
         self.__obj = weakref.ref(d['obj'])
         self.data = d['data']
-        self.attr = d['attr']
+        self.attr = getattr(d['obj'].__class__, self.key)
         
     obj = property(lambda s:s.__obj())
 
index 233c4458f3ed085e0467cf688b49c1a97bd4a43c..d3ca349316bb97045cfa53dc22d455f36afb2d95 100644 (file)
@@ -49,9 +49,9 @@ class AttributesTest(PersistTest):
         # shouldnt be pickling callables at the class level
         def somecallable(*args):
             return None
-        manager.register_attribute(MyTest, 'mt2', uselist = False, trackparent=True, callable_=somecallable)
+        manager.register_attribute(MyTest, 'mt2', uselist = True, trackparent=True, callable_=somecallable)
         x = MyTest()
-        x.mt2 = MyTest2()
+        x.mt2.append(MyTest2())
         
         x.user_id=7
         s = pickle.dumps(x)