From 15c86f3a570e76779be20d817a6a00fe7a9fa5bc Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Sun, 30 Nov 2014 10:58:11 -0600 Subject: [PATCH] Give our sqlalchemy objects access to their own session --- mediagoblin/db/base.py | 6 ++++++ 1 file changed, 6 insertions(+) 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): -- 2.25.1