def generate_save_context_path_from_uuid(self, uuid, do_children=True): """ Generates and saves a context path for a subject item by uuid """ cache = caches['redis'] cache.clear() output = False try: man_obj = Manifest.objects.get(uuid=uuid, item_type='subjects') except Manifest.DoesNotExist: man_obj = False if man_obj is not False: if man_obj.item_type == 'subjects': output = self.generate_save_context_path_from_manifest_obj( man_obj) if do_children: act_contain = Containment() act_contain.redis_ok = False # get the contents recusivelhy contents = act_contain.get_children_by_parent_uuid( uuid, True) if isinstance(contents, dict): for tree_node, children in contents.items(): for child_uuid in children: # do the children, but not recursively since we # already have a resurive look up of contents output = self.generate_save_context_path_from_uuid( child_uuid, False) return output
def generate_save_context_path_from_uuid(self, uuid, do_children=True): """ Generates and saves a context path for a subject item by uuid """ cache = caches['redis'] cache.clear() output = False try: man_obj = Manifest.objects.get(uuid=uuid, item_type='subjects') except Manifest.DoesNotExist: man_obj = False if man_obj is not False: if man_obj.item_type == 'subjects': output = self.generate_save_context_path_from_manifest_obj(man_obj) if do_children: act_contain = Containment() act_contain.redis_ok = False # get the contents recusivelhy contents = act_contain.get_children_by_parent_uuid(uuid, True) if isinstance(contents, dict): for tree_node, children in contents.items(): for child_uuid in children: # do the children, but not recursively since we # already have a resurive look up of contents output = self.generate_save_context_path_from_uuid(child_uuid, False) return output
def generate_context_path(self, uuid, include_self=True, delim='/'): """ generates a context path for a subject with a given uuid """ path = False act_contain = Containment() act_contain.redis_ok = False contexts = [] r_contexts = act_contain.get_parents_by_child_uuid(uuid) for tree_node, r_parents in r_contexts.items(): # now reverse the list of parent contexts, so top most parent context is first, # followed by children contexts contexts = r_parents[::-1] if (include_self): contexts.append(uuid) if (len(contexts) > 0): path_items = [] for p_uuid in contexts: try: act_p = Manifest.objects.get(uuid=p_uuid) path_items.append(act_p.label) except Manifest.DoesNotExist: return False path = delim.join(path_items) return path
def generate_context_path(self, uuid, include_self=True, delim='/'): """ generates a context path for a subject with a given uuid """ path = False act_contain = Containment() act_contain.redis_ok = False contexts = [] r_contexts = act_contain.get_parents_by_child_uuid(uuid) for tree_node, r_parents in r_contexts.items(): # now reverse the list of parent contexts, so top most parent context is first, # followed by children contexts contexts = r_parents[::-1] if(include_self): contexts.append(uuid) if(len(contexts) > 0): path_items = [] for p_uuid in contexts: try: act_p = Manifest.objects.get(uuid=p_uuid) path_items.append(act_p.label) except Manifest.DoesNotExist: return False path = delim.join(path_items) return path