示例#1
0
def hasImage(obj, **kwargs):
    """ Get image url
    """
    if not IRSSNewsItem.providedBy(obj):
        raise AttributeError

    try:
        image = obj.getField('image').getAccessor(obj)()
    except Exception:
        raise AttributeError
    else:
        return True if image else False
示例#2
0
def sourceUrl(obj, **kwargs):
    """ Index source url
    """
    if not IRSSNewsItem.providedBy(obj):
        raise AttributeError

    try:
        url = obj.getField('url').getAccessor(obj)()
    except Exception:
        raise AttributeError
    else:
        return url
示例#3
0
def sourceTitle(obj, **kwargs):
    """ Get source for catalog index """
    if not IRSSNewsItem.providedBy(obj):
        raise AttributeError

    found = False
    myparent = parent(obj)
    for _back in range(0, 5):
        if IRSSServer.providedBy(myparent):
            found = True
            break
        myparent = parent(myparent)

    if not found:
        raise AttributeError

    return myparent.title_or_id()