def begin():
"""begins a new UnitOfWork transaction. the next commit will affect only
objects that are created, modified, or deleted following the begin statement."""
- get_session().begin()
+ return get_session().begin()
def commit(*obj):
"""commits the current UnitOfWork transaction. if a transaction was begun
users.create()
assign_mapper(User, users)
try:
- objectstore.begin()
+ trans = objectstore.begin()
user = User()
user.user_name='fred'
user.password='*'
- objectstore.commit()
+ trans.commit()
# select
sqluser = User.select_by(user_name='fred')[0]
module_engine.connect(db_uri)
users.create()
try:
- objectstore.begin()
+ trans = objectstore.begin()
all = User.select()[:]
assert all == []
u = User()
u.user_name = uname
u.password = 'whatever'
- objectstore.commit()
+ trans.commit()
names = [ us.user_name for us in User.select() ]
assert names == [ uname ]