mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-06-03 06:19:59 -04:00
4a6afd469f
0.4 development continues at /sqlalchemy/branches/rel_0_4
32 lines
615 B
Python
32 lines
615 B
Python
from sqlalchemy.orm import attributes
|
|
class Foo(object):pass
|
|
attributes.register_class(Foo)
|
|
attributes.register_attribute(Foo, 'x', uselist=False, useobject=False, mutable_scalars=True, copy_function=lambda x:x.copy())
|
|
|
|
f = Foo()
|
|
f._foostate.set_savepoint()
|
|
print f._foostate.get_history('x')
|
|
|
|
f.x = {'1':15}
|
|
|
|
|
|
print f._foostate.get_history('x')
|
|
f._foostate.commit_all()
|
|
|
|
print f._foostate.get_history('x')
|
|
|
|
f.x['2'] = 40
|
|
print f._foostate.get_history('x')
|
|
|
|
f._foostate.rollback()
|
|
|
|
print f._foostate.get_history('x')
|
|
|
|
#import pdb
|
|
#pdb.Pdb().break_here()
|
|
|
|
print f.x
|
|
f.x['2'] = 40
|
|
print f._foostate.get_history('x')
|
|
|