from aspen import Response
from psycopg2 import IntegrityError

# ========================================================================== ^L

if user.ANON:
    raise Response(404)

new_participant_id = request.body['participant_id']

try:
    user.change_id(new_participant_id)
    response.body = {"participant_id": new_participant_id}
except IntegrityError:
    raise Response(409)  # Conflict

from aspen import Response
from gittip.models import Participant

# ========================================================================== ^L

if user.ANON:
    raise Response(404)

new_participant_id = request.body['participant_id']

try:
    user.change_id(new_participant_id)
    response.body = {"participant_id": new_participant_id}
except Participant.IdContainsInvalidCharacters, Participant.IdIsRestricted:
    raise Response(400)
except Participant.IdAlreadyTaken:
    raise Response(409)
except Participant.IdTooLong:
    raise Response(413)

Raise appropriate response based on exception raised by Participant
Raise appropriate response based on exception raised by Participant

Signed-off-by: Joonas Bergius <9be13466ab086d7a8db93edb14ffb6760790b15e@gmail.com>
