コード例 #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
ファイル: site.py プロジェクト: amarandon/opencore
def get_textrepr(object, default):
    adapter = queryAdapter(object, ITextIndexData)
    if adapter is not None:
        text = adapter()
        return text
    elif (IContent.providedBy(object)):
        fmt = "%s %s"
        tr = fmt % (
            getattr(object, 'title', ''),
            getattr(object, 'description', ''),
            )
        return tr
    return default
コード例 #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
コード例 #4
0
def evolve(context):
    catalog = find_catalog(context)
    index = catalog['texts']
    for docid in index.index._docweight.keys():
        try:
            path = catalog.document_map.address_for_docid(docid)
            context = find_resource(context, path)
            if (ICalendarLayer.providedBy(context) or
                ICalendarCategory.providedBy(context) or
                not IContent.providedBy(context)):
                index.unindex_doc(docid)

            if hasattr(context, '_p_deactivate'):
                context._p_deactivate()
        except KeyError:
            # Work around some bad data in the db--some calendar categories
            # got added with '/' characters in their ids.  Skip them for now
            # until we can figure out what to do with them.
            print "Bad path in catalog: ", path
コード例 #5
0
ファイル: evolve5.py プロジェクト: boothead/karl
def evolve(context):
    catalog = find_catalog(context)
    index = catalog['texts']
    for docid in index.index._docweight.keys():
        try:
            path = catalog.document_map.address_for_docid(docid)
            context = find_model(context, path)
            if (ICalendarLayer.providedBy(context) or
                ICalendarCategory.providedBy(context) or
                not IContent.providedBy(context)):
                index.unindex_doc(docid)

            if hasattr(context, '_p_deactivate'):
                context._p_deactivate()
        except KeyError:
            # Work around some bad data in the db--some calendar categories
            # got added with '/' characters in their ids.  Skip them for now
            # until we can figure out what to do with them.
            print "Bad path in catalog: ", path