'Set a user preference asynchronously. If user is not logged in, do nothing.'

@web.expose
def set_user_pref_async(self, trans, pref_name, pref_value):

    if trans.user:
        trans.log_action(trans.get_user(), 'set_user_pref', '', {pref_name: pref_value})
        trans.user.preferences[pref_name] = pref_value
        trans.sa_session.flush()
