Example #1
0
class MiniSession:
    """
    A DB session that lasts for as long as a web request. Makes sure that
    nothing stays in memory between requests, because we're not paying for a
    server that lets us use a lot of memory.
    """
    def __enter__(self):
        self.session = Session()
        return self.session

    def __exit__(self, type, value, traceback):
        self.session.close()
        del self.session
Example #2
0
 def __enter__(self):
     self.session = Session()
     return self.session