def user_keys(self, users, min=None, max=None, limit=100, tag=None): if not users: return () if users == str(users): # single user optimization userid = users mapping = self._user_mapping.get(userid) if not mapping: return () else: # collection of user LLTreeSet treesets = (self._user_mapping.get(userid) for userid in users if userid in self._user_mapping.keys()) mapping = reduce(LLBTree.union, treesets, LLBTree.TreeSet()) if tag: if tag not in self._tag_mapping: return () mapping = LLBTree.intersection(mapping, self._tag_mapping[tag]) return longkeysortreverse(mapping, min, max, limit)
def keys(self, min=None, max=None, limit=100, tag=None): self._check_permission("read") if tag: if tag not in self._tag_mapping: return () mapping = LLBTree.intersection( LLBTree.LLTreeSet(self._status_mapping.keys()), self._tag_mapping[tag]) else: mapping = self._status_mapping return longkeysortreverse(mapping, min, max, limit)
def secure(self, keyset): """Filter keyset to return only keys the current user may see. NB this may return statusupdates with a microblog_context (workspace) accessible to the user, but referencing a content_context (document) which the user may not access yet because of content workflow. Filtering that is quite costly and not done here - instead there's a postprocessing filter in activitystream just before rendering. """ return LLBTree.intersection( LLBTree.LLTreeSet(keyset), LLBTree.LLTreeSet(self.allowed_status_keys()))
def _keys_uuid(self, uuid, keyset): if uuid is None: return keyset return LLBTree.intersection( LLBTree.LLTreeSet(keyset), self._uuid_mapping[uuid])
def _keys_tag(self, tag, keyset): if tag is None: return keyset return LLBTree.intersection( LLBTree.LLTreeSet(keyset), self._tag_mapping[tag])
def _keys_mention(self, mention, keyset): if mention is None: return keyset return LLBTree.intersection( LLBTree.LLTreeSet(keyset), self._mentions_mapping[mention])
def _keys_uuid(self, uuid, keyset): if uuid is None: return keyset return LLBTree.intersection(LLBTree.LLTreeSet(keyset), self._uuid_mapping[uuid])
def _keys_tag(self, tag, keyset): if tag is None: return keyset return LLBTree.intersection(LLBTree.LLTreeSet(keyset), self._tag_mapping[tag])
def _keys_mention(self, mention, keyset): if mention is None: return keyset return LLBTree.intersection(LLBTree.LLTreeSet(keyset), self._mentions_mapping[mention])
def secure(self, keyset): """Filter keyset to return only keys the current user may see.""" return LLBTree.intersection( LLBTree.LLTreeSet(keyset), LLBTree.LLTreeSet(self.allowed_status_keys()))