def getValue(self): try: util = get_utility_for_context(ISearchableArchive, context=self.context) except ComponentLookupError: return 0 return len(util.getToplevelMessages())
def __init__(self, context): self.context = context # This is called during message creation (e.g. from Application), so # context needs to be passed explicitly. self.search = get_utility_for_context(ISearchableArchive, context=context) self.annotations = IAnnotations(context) self.list_data = self.annotations.get(PROJECTNAME) self._refs_calculated = False if self.list_data is None: self.list_data = self.annotations[PROJECTNAME] = OOBTree()
def __init__(self, context): self.context = context # This is called during message creation (e.g. from Application), so # context needs to be passed explicitly. self.search = get_utility_for_context(ISearchableArchive, context=context) self.annotations = IAnnotations(context) self.list_data = self.annotations.get(PROJECTNAME) self._refs_calculated = False if self.list_data is None: self.list_data = self.annotations[PROJECTNAME] = OOBTree()
def SearchableListMoved(ml, event): if not IObjectRemovedEvent.providedBy(event): # don't bother with this stuff on removal, it's pointless search = get_utility_for_context(ISearchableArchive, context=ml) # XXX: Assumes a ZCatalog based utility, we need to rebuild the whole # catalog after a move # Clear the catalog search.manage_catalogClear() # Add the moved messages to the catalog, then reindex again to make sure # that we don't get any threading inconsistencies. index_meth = search.catalog_object path = '/'.join(ml.getPhysicalPath()) search.ZopeFindAndApply(ml, obj_metatypes=('MailingListMessage',), apply_func=index_meth, apply_path=path, search_sub=1) search.refreshCatalog()