Пример #1
0
def _save_cached_profile(user_id: UserId, user: UserSpec, multisite_keys: List[str],
                         non_contact_keys: List[str]) -> None:
    # Only save contact AND multisite attributes to the profile. Not the
    # infos that are stored in the custom attribute files.
    cache = {}
    for key in user.keys():
        if key in multisite_keys or key not in non_contact_keys:
            cache[key] = user[key]

    save_cached_profile(user_id, cache)
Пример #2
0
def _set_user_attribute(key: str, value: Optional[str]):
    assert config.user.id is not None
    user_id = config.user.id
    cached_profile = load_cached_profile(config.user.id)
    if cached_profile is None:
        raise MKUserError(None, _("Could not load cached user profile."))

    cached_profile[key] = value
    save_cached_profile(user_id, cached_profile)
    userdb.save_custom_attr(user_id, key, value)