def sessioned(func):
    def with_session(self, *args, **kw):
        if 'session' in kw:
            return func(self, *args, **kw)
        else:
            with self.in_session() as session:
                kw['session'] = session
                retval = func(self, *args, **kw)
            return retval

    return with_session
dataset/ETHPy150Open openstack/stacktach-winchester/winchester/db/interface.py/sessioned/original