'Associate an OpenID with a user account.'

def associate_openid(self, user, openid_response):

    try:
        user_openid = UserOpenID.objects.get(claimed_id__exact=openid_response.identity_url)
    except UserOpenID.DoesNotExist:
        user_openid = UserOpenID(user=user, claimed_id=openid_response.identity_url, display_id=openid_response.endpoint.getDisplayIdentifier())
        user_openid.save()
    else:
        if (user_openid.user != user):
            raise IdentityAlreadyClaimed(('The    identity    %s    has    already    been    claimed' % openid_response.identity_url))
    return user_openid
