From e248e1429a832c7b38094fe08155f163ffc6b9b2 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Sun, 30 Nov 2014 14:04:09 -0600 Subject: [PATCH] Some docstrings --- mediagoblin/db/open.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mediagoblin/db/open.py b/mediagoblin/db/open.py index 9922cc10..81cd019c 100644 --- a/mediagoblin/db/open.py +++ b/mediagoblin/db/open.py @@ -59,12 +59,25 @@ else: from sqlalchemy.orm import sessionmaker class DatabaseManager(object): + """ + Manage database connections. + + The main method here is session_scope which can be used with a + "with" statement to get a session that is properly torn down + by the end of execution. + """ def __init__(self, engine): self.engine = engine self.Session = sessionmaker(bind=engine) @contextmanager def session_scope(self): + """ + This is a context manager, use like:: + + with dbmanager.session_scope() as request.db: + some_view(request) + """ session = self.Session() #####################################