From: Christopher Allan Webber Date: Sun, 30 Nov 2014 16:58:11 +0000 (-0600) Subject: Give our sqlalchemy objects access to their own session X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=15c86f3a570e76779be20d817a6a00fe7a9fa5bc;p=mediagoblin.git Give our sqlalchemy objects access to their own session --- diff --git a/mediagoblin/db/base.py b/mediagoblin/db/base.py index 38375a69..e254e810 100644 --- a/mediagoblin/db/base.py +++ b/mediagoblin/db/base.py @@ -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):