def _mapItemToCacheKeyItem(self, item): key = item rerender = False sidebar = Block.Block.findBlockByName ("Sidebar") """ collectionList should be in the order that the source items are overlayed in the Calendar view """ collectionList = [theItem for theItem in sidebar.contents if (theItem in sidebar.checkedItems) and (theItem is not item)] if isinstance (item, ItemCollection): collectionList.insert (0, item) if len (collectionList) > 0: """ tupleList is sorted so we always end up with on collection for any order of collections in the source """ tupleList = [theItem.itsUUID for theItem in collectionList] tupleList.sort() filterKind = sidebar.filterKind if not filterKind is None: tupleList.append (filterKind.itsUUID) if len (tupleList) > 1: tupleKey = tuple (tupleList) try: key = self.itemTupleKeyToCacheKey [tupleKey] except KeyError: """ We need to make a new filtered item collection that depends upon the unfiltered collection. Unfortunately, making a new ItemCollection with a rule whose results include all items in the original ItemCollection has a problem: when the results in the unfiltered ItemCollection change we don't get notified. Alternatively we make a copy of the ItemCollection (and it's rule) which has another problem: When the rule in the original ItemCollection change we don't update our copied rule. """ key = ItemCollection(view=self.itsView) key.source = collectionList displayName = u" and ".join ([theItem.displayName for theItem in collectionList]) if filterKind is not None: key.addFilterKind (filterKind) displayName += u" filtered by " + filterKind.displayName key.displayName = displayName self.itemTupleKeyToCacheKey [tupleKey] = key else: """ Check to see if we need to reorder the source list. The list is kept sorted by the order of the collections as they overlay one another. We don't bother to sort when we're looking up a collection that isn't displayed in the summary view, both because it's not necessary and because it causes the source attribute to change which causes a notification to update the sidebar, which causes the order to change, causing a notification, ... repeating forever. """ if sidebar.selectedItemToView is item: for new, old in map (None, key.source, collectionList): if new is not old: key.source = collectionList rerender = True break return key, rerender