close db session per change

This commit is contained in:
j 2015-12-25 20:20:08 +05:30
parent f8c09226de
commit d817c67f83
2 changed files with 7 additions and 7 deletions

View file

@ -65,6 +65,7 @@ class Changelog(db.Model):
def apply_changes(cls, user, changes): def apply_changes(cls, user, changes):
trigger = changes trigger = changes
for change in changes: for change in changes:
with db.session():
if not cls.apply_change(user, change, trigger=False): if not cls.apply_change(user, change, trigger=False):
logger.debug('FAIL %s', change) logger.debug('FAIL %s', change)
trigger = False trigger = False

View file

@ -297,7 +297,6 @@ class Node(Thread):
return False return False
if not changes: if not changes:
return False return False
with db.session():
r = Changelog.apply_changes(self.user, changes) r = Changelog.apply_changes(self.user, changes)
return r return r