Give our sqlalchemy objects access to their own session

This commit is contained in:
Christopher Allan Webber 2014-11-30 10:58:11 -06:00
parent d71499004f
commit 15c86f3a57

View File

@ -17,11 +17,17 @@
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import scoped_session, sessionmaker, object_session
from sqlalchemy import inspect
Session = scoped_session(sessionmaker())
class GMGTableBase(object):
@property
def _session(self):
return inspect(self).session
query = Session.query_property()
def get(self, key):