Request-bound database connection.

def connection(self):
        """Request-bound database connection."""
        assert flask.has_request_context(), \
               'tried to connect zodb outside request'
        if not self.is_connected:
            connector = flask.current_app.extensions['zodb']
            flask._request_ctx_stack.top.zodb_connection = connector.db.open()
            transaction.begin()
        return flask._request_ctx_stack.top.zodb_connection