'For the benefit of subclasses, to lookup attributes which may
require more work than a simple getattr (for example, \'author\'
which has to be gotten from the author_id attribute on most
things).'

def thing_attr(self, thing, attr):

    if (attr == 'author'):
        if thing.author._deleted:
            return '[deleted]'
        return thing.author.name
    if (attr == 'created'):
        return time.mktime(thing._date.timetuple())
    elif (attr == 'created_utc'):
        return (time.mktime(thing._date.astimezone(pytz.UTC).timetuple()) - time.timezone)
    elif (attr == 'child'):
        child = getattr(thing, 'child', None)
        if child:
            return child.render()
        else:
            return ''
    if (attr == 'distinguished'):
        distinguished = getattr(thing, attr, 'no')
        if (distinguished == 'no'):
            return None
        return distinguished
    return getattr(thing, attr, None)
