@contextmanager
def current_user(user):
 old_user = get_current_user()
 set_current_user(user)
 (yield)
 set_current_user(old_user)

@ contextmanager def current_user ( user ) : old_user = get_current_user ( ) set_current_user ( user ) ( yield ) set_current_user ( old_user )
changes the current user just within a context .