def account_groups_and_extra_data(account, resource,
                                  refresh_timedelta=None):
    """Fetch account groups and extra data from resource if necessary."""
    updated = datetime.utcnow()
    modified_since = updated
    if refresh_timedelta is not None:
        modified_since += refresh_timedelta
    modified_since = modified_since.isoformat()
    last_update = account.extra_data.get('updated', modified_since)

    if last_update > modified_since:
        return account.extra_data.get('groups', [])

    groups = fetch_groups(resource['Group'])
    extra_data = current_app.config.get(
        'OAUTHCLIENT_CERN_EXTRA_DATA_SERIALIZER',
        fetch_extra_data
    )(resource)

    account.extra_data.update(
        groups=groups,
        updated=updated.isoformat(),
        **extra_data
    )
    return groups
def account_groups_and_extra_data ( account , resource , refresh_timedelta = None ) : updated = datetime . utcnow ( ) modified_since = updated if refresh_timedelta is not None : modified_since += refresh_timedelta modified_since = modified_since . isoformat ( ) last_update = account . extra_data . get ( 'updated' , modified_since ) if last_update > modified_since : return account . extra_data . get ( 'groups' , [ ] ) groups = fetch_groups ( resource [ 'Group' ] ) extra_data = current_app . config . get ( 'OAUTHCLIENT_CERN_EXTRA_DATA_SERIALIZER' , fetch_extra_data ) ( resource ) account . extra_data . update ( groups = groups , updated = updated . isoformat ( ) , ** extra_data ) return groups
Fetch account groups and extra data from resource if necessary.