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
def _get_calendar_layers(context): layers = [ x for x in context.values() if ICalendarLayer.providedBy(x) ] for layer in layers: layer._v_categories = [] for path in layer.paths: category = {} try: calendar = find_model(context, path) title = _calendar_category_title(calendar) category['title'] = title layer._v_categories.append(category) except KeyError: continue return layers
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
def get_textrepr(object, default): adapter = queryAdapter(object, ITextIndexData) if adapter is not None: text = adapter() return text elif (IContent.providedBy(object) and not (ICalendarLayer.providedBy(object) or ICalendarCategory.providedBy(object))): fmt = "%s %s" tr = fmt % ( getattr(object, 'title', ''), getattr(object, 'description', ''), ) return tr return default
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
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