accountant-ui/api/model/__init__.py

32 lines
713 B
Python
Raw Normal View History

2013-12-03 22:22:25 +01:00
from contextlib import contextmanager
from flask.ext.sqlalchemy import SQLAlchemy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import scoped_session, sessionmaker
db = SQLAlchemy()
@contextmanager
2013-12-03 23:01:17 +01:00
def session_scope():
#session = scoped_session(sessionmaker(autocommit = False, autoflush = False, bind = engine))
session = db.session
#Base.query = session.query_property()
try:
yield session
session.commit()
except:
session.rollback()
raise
finally:
session.close()
2013-12-03 22:22:25 +01:00
import pkgutil
__all__ = []
for loader, module_name, is_pkg in pkgutil.walk_packages(__path__):
__all__.append(module_name)
from . import *