- 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]
0.2.6
- big overhaul to schema to allow truly composite primary and foreign
def hasparent(self, item):
"""returns True if the given item is attached to a parent object
via the attribute represented by this InstrumentedAttribute."""
- return item._state.get(('hasparent', self))
+ return item._state.get(('hasparent', id(self)))
def sethasparent(self, item, value):
"""sets a boolean flag on the given item corresponding to whether or not it is
attached to a parent object via the attribute represented by this InstrumentedAttribute."""
if item is not None:
- item._state[('hasparent', self)] = value
+ item._state[('hasparent', id(self))] = value
def get_history(self, obj, passive=False):
"""return a new AttributeHistory object for the given object/this attribute's key.
class MyTest(object):pass
+class MyTest2(object):pass
class AttributesTest(PersistTest):
"""tests for the attributes.py module, which deals with tracking attribute changes on an object."""
manager.register_attribute(MyTest, 'user_id', uselist = False)
manager.register_attribute(MyTest, 'user_name', uselist = False)
manager.register_attribute(MyTest, 'email_address', uselist = False)
+ manager.register_attribute(MyTest2, 'a', uselist = False)
+ manager.register_attribute(MyTest2, 'b', uselist = False)
+ # shouldnt be pickling callables at the class level
+ def somecallable(*args):
+ return None
+ manager.register_attribute(MyTest, 'mt2', uselist = False, trackparent=True, callable_=somecallable)
x = MyTest()
+ x.mt2 = MyTest2()
+
x.user_id=7
s = pickle.dumps(x)
x2 = pickle.loads(s)