Ejemplo n.º 1
0
def update_author(xml):
    "Executes xml, creates author or updates inf about it."
    entity_id = get_id(xml)

    if entity_id is None:
        # Create new author
        author = Author()
    else:
        # Modify existing author
        author = Author.objects.get(id=entity_id)

    full_name = get_tag_text(xml, 'full_name')

    if full_name:
        author.name = full_name
    
    if not author.name:
        raise IntegrityError("'full_name' can't be empty")

    try:
        credit_str = get_tag_text(xml, 'credit')
        if credit_str:
            credit = int(credit_str)
            author.credit = credit
    except ValueError, ex:
        raise InputDataServerException(ex)