- repaired non-working attributes.set_committed_value function.

This commit is contained in:
Mike Bayer
2009-06-18 19:37:16 +00:00
parent 8a72a5b0bc
commit cea9cc5e8e
3 changed files with 29 additions and 1 deletions
+2
View File
@@ -45,6 +45,8 @@ CHANGES
columns, has been enhanced such that the fk->itself aspect of the
relation won't be used to determine relation direction.
- repaired non-working attributes.set_committed_value function.
- Trimmed the pickle format for InstanceState which should further
reduce the memory footprint of pickled instances. The format
should be backwards compatible with that of 0.5.4 and previous.
+1 -1
View File
@@ -1418,7 +1418,7 @@ def set_committed_value(instance, key, value):
"""
state, dict_ = instance_state(instance), instance_dict(instance)
state.get_impl(key).set_committed_value(state, dict_, key, value)
state.get_impl(key).set_committed_value(state, dict_, value)
def set_attribute(instance, key, value):
"""Set the value of an attribute, firing history events.
+26
View File
@@ -512,6 +512,32 @@ class AttributesTest(_base.ORMTest):
except sa_exc.ArgumentError, e:
assert False
class UtilTest(_base.ORMTest):
def test_helpers(self):
class Foo(object):
pass
class Bar(object):
pass
attributes.register_class(Foo)
attributes.register_class(Bar)
attributes.register_attribute(Foo, "coll", uselist=True, useobject=True)
f1 = Foo()
b1 = Bar()
b2 = Bar()
coll = attributes.init_collection(f1, "coll")
assert coll.data is f1.coll
assert attributes.get_attribute(f1, "coll") is f1.coll
attributes.set_attribute(f1, "coll", [b1])
assert f1.coll == [b1]
eq_(attributes.get_history(f1, "coll"), ([b1], [], []))
attributes.set_committed_value(f1, "coll", [b2])
eq_(attributes.get_history(f1, "coll"), ((), [b2], ()))
attributes.del_attribute(f1, "coll")
assert "coll" not in f1.__dict__
class BackrefTest(_base.ORMTest):