def context_keys(self, context, min=None, max=None, limit=100, tag=None, nested=True, mention=None): if tag and tag not in self._tag_mapping: return () if nested: # hits portal_catalog nested_uuids = [uuid for uuid in self.nested_uuids(context) if uuid in self._uuid_mapping] if not nested_uuids: return () else: # used in test_statuscontainer_context for non-integration tests uuid = self._context2uuid(context) if uuid not in self._uuid_mapping: return () nested_uuids = [uuid] # tag and uuid filters handle None inputs gracefully keyset_tag = self._keys_tag(tag, self.allowed_status_keys()) # mention and uuid filters handle None inputs gracefully keyset_mention = self._keys_tag(mention, keyset_tag) # calculate the tag+mention+uuid intersection for each uuid context keyset_uuids = [self._keys_uuid(_uuid, keyset_mention) for _uuid in nested_uuids] # merge the intersections merged_set = LLBTree.multiunion(keyset_uuids) merged_set = self.secure(merged_set) return longkeysortreverse(merged_set, min, max, limit)
def context_keys(self, context, min=None, max=None, limit=100, tag=None, nested=True): self._check_permission("read") if tag and tag not in self._tag_mapping: return () if nested: # hits portal_catalog nested_uuids = [uuid for uuid in self.nested_uuids(context) if uuid in self._uuid_mapping] if not nested_uuids: return () else: # used in test_statuscontainer_context for non-integration tests uuid = self._context2uuid(context) if uuid not in self._uuid_mapping: return () nested_uuids = [uuid] # tag and uuid filters handle None inputs gracefully keyset_tag = self._keys_tag(tag, self.allowed_status_keys()) # calculate the tag+uuid intersection for each uuid context keyset_uuids = [self._keys_uuid(uuid, keyset_tag) for uuid in nested_uuids] # merge the intersections merged_set = LLBTree.multiunion(keyset_uuids) return longkeysortreverse(merged_set, min, max, limit)
def _query_mapping(self, mapping, keys): """ Calculate the union of all statusids indexed in <mapping> on any of the <keys>. Always returns an LLTreeSet ready for further processing. """ if not keys: return LLBTree.LLTreeSet() elif isinstance(keys, (str, unicode)): # convert single key to list keys = [keys] # calculate the union set of matching ids across all tags # silently discards all non-existing key ids treesets = [mapping.get(id) for id in keys if id in mapping.keys()] return LLBTree.multiunion(treesets)