Cleanup after database use

This commit is contained in:
Ruud
2012-05-07 21:55:18 +02:00
parent 7a6576e407
commit 7ca509cdbe
16 changed files with 78 additions and 28 deletions
+9 -1
View File
@@ -47,6 +47,7 @@ class ProfilePlugin(Plugin):
for profile in profiles:
temp.append(profile.to_dict(self.to_dict))
db.close()
return temp
def save(self):
@@ -83,6 +84,7 @@ class ProfilePlugin(Plugin):
profile_dict = p.to_dict(self.to_dict)
db.close()
return jsonified({
'success': True,
'profile': profile_dict
@@ -92,8 +94,10 @@ class ProfilePlugin(Plugin):
db = get_session()
default = db.query(Profile).first()
default_dict = default.to_dict(self.to_dict)
db.close()
return default.to_dict(self.to_dict)
return default_dict
def saveOrder(self):
@@ -109,6 +113,7 @@ class ProfilePlugin(Plugin):
order += 1
db.commit()
db.close()
return jsonified({
'success': True
@@ -133,6 +138,8 @@ class ProfilePlugin(Plugin):
message = 'Failed deleting Profile: %s' % e
log.error(message)
db.close()
return jsonified({
'success': success,
'message': message
@@ -180,4 +187,5 @@ class ProfilePlugin(Plugin):
order += 1
db.close()
return True