setattr/delattr used on a hybrid that doesn't
define fset or fdel. [ticket:2353]
+ - [bug] Fixed bug where unpickled object didn't
+ have enough of its state set up to work
+ correctly within the unpickle() event established
+ by the mutable object extension, if the object
+ needed ORM attribute access within
+ __eq__() or similar. [ticket:2362]
+
- sql
- [feature] Added "false()" and "true()" expression
constructs to sqlalchemy.sql namespace, though
if 'load_path' in state:
self.load_path = interfaces.deserialize_path(state['load_path'])
+ # setup _sa_instance_state ahead of time so that
+ # unpickle events can access the object normally.
+ # see [ticket:2362]
+ manager.setup_instance(inst, self)
manager.dispatch.unpickle(self, state)
def initialize(self, key):
class SubFoo(Foo):
pass
+class FooWithEq(object):
+ def __init__(self, **kw):
+ for k in kw:
+ setattr(self, k, kw[k])
+ def __eq__(self, other):
+ return self.id == other.id
+
class _MutableDictTestBase(object):
run_define_tables = 'each'
return self.x, self.y
def __getstate__(self):
- d = dict(self.__dict__)
- d.pop('_parents', None)
- return d
+ return self.x, self.y
- #def __setstate__(self, state):
- # self.x, self.y = state
+ def __setstate__(self, state):
+ self.x, self.y = state
def __eq__(self, other):
return isinstance(other, Point) and \
other.y == self.y
return Point
+class MutableCompositesUnpickleTest(_CompositeTestBase, fixtures.MappedTest):
+
+ @classmethod
+ def setup_mappers(cls):
+ foo = cls.tables.foo
+
+ cls.Point = cls._type_fixture()
+
+ mapper(FooWithEq, foo, properties={
+ 'data':composite(cls.Point, foo.c.x, foo.c.y)
+ })
+
+ def test_unpickle_modified_eq(self):
+ u1 = FooWithEq(data=self.Point(3, 5))
+ for loads, dumps in picklers():
+ loads(dumps(u1))
+
class MutableCompositesTest(_CompositeTestBase, fixtures.MappedTest):
@classmethod