Merge "The 'model_save' helper added to the context."

This commit is contained in:
Jenkins 2013-06-04 17:53:55 +00:00 committed by Gerrit Code Review
commit 09f8930578

View File

@ -61,3 +61,10 @@ def set_ctx(new_ctx):
def model_query(model, context=None): def model_query(model, context=None):
context = context or ctx() context = context or ctx()
return context.session.query(model) return context.session.query(model)
def model_save(model, context=None):
context = context or ctx()
with context.session.begin():
context.session.add(model)
return model