示例#1
0
文件: site.py 项目: hj91/karl
def _get_texts(object, default):
    if IPhoto.providedBy(object):
        return default

    adapter = queryAdapter(object, ITextIndexData)
    if adapter is None:
        if not IContent.providedBy(object) or ICalendarLayer.providedBy(object) or ICalendarCategory.providedBy(object):
            return default
        adapter = FlexibleTextIndexData(object)
    texts = adapter()
    if not texts:
        return default
    return texts
示例#2
0
def evolve(site):
    """
    Add the IPhoto marker interface to profile and news item photos.
    """
    catalog = find_catalog(site)
    search = ICatalogSearch(site)
    count, docids, resolver = search(
        interfaces={'operator': 'or', 'query': [INewsItem, IProfile]})
    for docid in docids:
        doc = resolver(docid)
        photo = doc.get('photo')
        if photo is not None and not IPhoto.providedBy(photo):
            alsoProvides(photo, IPhoto)
            catalog.reindex_doc(photo.docid, photo)
示例#3
0
def _get_texts(object, default):
    if IPhoto.providedBy(object):
        return default

    adapter = queryAdapter(object, ITextIndexData)
    if adapter is None:
        if (not IContent.providedBy(object)
                or ICalendarLayer.providedBy(object)
                or ICalendarCategory.providedBy(object)):
            return default
        adapter = FlexibleTextIndexData(object)
    texts = adapter()
    if not texts:
        return default
    return texts