def getname(obj):
    """
    Abstracts the common pattern of allowing both an object or an object's NAME
    as a parameter when dealing with relationships.
    """
    try:
        return obj.name
    except AttributeError:
        return obj
