def update_oauth(request):
    o = None
    created = False
    try:
        o = OAuth.get(username=request.user)
    except Process.DoesNotExist:
        o = OAuth(username=request.user,
                  consumer_key=request.FORM.consumer_key,
                  consumer_secret=request.FORM.consumer_secret,
                  scope=request.FORM.scope)
        created = True

    if not created and o is not None:
        o.consumer_key = request.FORM.consumer_key
        o.consumer_secret = request.FORM.consumer_secret
        o.realm = request.FORM.realm
    o.save()
def update_oauth(request):
    o = None
    created = False
    try:
        o = OAuth.get(username=request.user)
    except Process.DoesNotExist:
        o = OAuth(
            username=request.user,
            consumer_key=request.FORM.consumer_key,
            consumer_secret=request.FORM.consumer_secret,
            scope=request.FORM.scope
        )
        created = True

    if not created and o is not None:
        o.consumer_key = request.FORM.consumer_key
        o.consumer_secret = request.FORM.consumer_secret
        o.realm = request.FORM.realm
    o.save()