Repository :
http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
---------------------------------------------------------------
commit 47592aaaf0ad4d74ba57b497f4f2ff0bc0f342cb
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Fri Mar 1 11:39:57 2013 +0100
Have the create_table function return a valid scoped session
---------------------------------------------------------------
fedocal/fedocallib/model.py | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/fedocal/fedocallib/model.py b/fedocal/fedocallib/model.py
index 24e218c..160f088 100644
--- a/fedocal/fedocallib/model.py
+++ b/fedocal/fedocallib/model.py
@@ -36,13 +36,14 @@ from sqlalchemy import (
)
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
+from sqlalchemy.orm import scoped_session
from sqlalchemy.orm import relation as relationship
from sqlalchemy.sql import and_
BASE = declarative_base()
-def create_tables(db_url, alembic_ini=None, debug=False):
+def create_tables(db_url, alembic_ini=None, debug=True):
""" Create the tables in the database using the information from the
url obtained.
@@ -67,8 +68,8 @@ def create_tables(db_url, alembic_ini=None, debug=False):
alembic_cfg = Config(alembic_ini)
command.stamp(alembic_cfg, "head")
- sessionmak = sessionmaker(bind=engine)
- return sessionmak()
+ scopedsession = scoped_session(sessionmaker(bind=engine))
+ return scopedsession
class Calendar(BASE):