def dbtransaction(func):
    """ Wrapper to rollback db changes if there's an exception """
    def wrapper(self, *args, **kwargs):
        try:
            func(self, *args, **kwargs)
            self._db.commit()
        except Exception as e:
            self._db.rollback()
            raise e
    return wrapper