From 688755c5429b19a30d2d9e0ca6101202ac030ded Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Fri, 25 Jan 2013 12:53:49 +0100 Subject: [PATCH] Fixed session retrieving. --- src/api/controller/accounts.py | 10 +++++----- src/api/controller/entries.py | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/api/controller/accounts.py b/src/api/controller/accounts.py index 3ac705d..6691fe4 100644 --- a/src/api/controller/accounts.py +++ b/src/api/controller/accounts.py @@ -14,7 +14,7 @@ def get_accounts(): """ Returns accounts with their solds. """ - session = db.create_scoped_session() + session = db.session query = session.query( Account.id.label("id"), @@ -36,7 +36,7 @@ def get_accounts(): @app.route("/api/accounts//months") def get_months(account_id): - session = db.create_scoped_session() + session = db.session query = session.query( distinct(extract("year", Entry.value_date)).label("year"), @@ -50,7 +50,7 @@ def get_months(account_id): @app.route("/api/accounts", methods=["PUT"]) def add_account(): - session = db.create_scoped_session() + session = db.session try: account = Account(request.json['name'], request.json['authorized_overdraft']) @@ -66,7 +66,7 @@ def add_account(): @app.route("/api/accounts/", methods=["PUT"]) def update_account(account_id): - session = db.create_scoped_session() + session = db.session try: account = session.query(Account).filter(Account.id == account_id).first() @@ -84,7 +84,7 @@ def update_account(account_id): @app.route("/api/accounts/", methods=["DELETE"]) def delete_account(account_id): - session = db.create_scoped_session() + session = db.session try: account = session.query(Account).filter(Account.id == account_id).first() diff --git a/src/api/controller/entries.py b/src/api/controller/entries.py index eec3059..f31c466 100644 --- a/src/api/controller/entries.py +++ b/src/api/controller/entries.py @@ -17,7 +17,7 @@ def get_entries(account_id, year, month): """ Return entries for an account, year, and month. """ - session = db.create_scoped_session() + session = db.session query = session.query( Entry @@ -46,7 +46,7 @@ def get_entries(account_id, year, month): @app.route("/api/entries", methods=["PUT"]) def add_entry(): - session = db.create_scoped_session() + session = db.session try: entry = Entry( @@ -68,7 +68,7 @@ def add_entry(): @app.route("/api/entries/", methods=["PUT"]) def update_entry(entry_id): - session = db.create_scoped_session() + session = db.session try: entry = session.query(Entry).filter(Entry.id == entry_id).first() @@ -91,7 +91,7 @@ def update_entry(entry_id): @app.route("/api/entries/", methods=["DELETE"]) def delete_entry(entry_id): - session = db.create_scoped_session() + session = db.session try: entry = session.query(Entry).filter(Entry.id == entry_id).first()