def _get_descendent_cat_idstrs(self, cat_id, hierarchy_session=None):
def get_descendent_ids(h_session):<EOL><INDENT>idstr_list = [str(cat_id)]<EOL>if h_session is None:<EOL><INDENT>pkg_name = cat_id.get_identifier_namespace().split('<STR_LIT:.>')[<NUM_LIT:0>]<EOL>cat_name = cat_id.get_identifier_namespace().split('<STR_LIT:.>')[<NUM_LIT:1>]<EOL>try:<EOL><INDENT>mgr = self._get_provider_manager('<STR_LIT>')<EOL>h_session = mgr.get_hierarchy_traversal_session_for_hierarchy(<EOL>Id(authority=pkg_name.upper(),<EOL>namespace='<STR_LIT>',<EOL>identifier=cat_name.upper()),<EOL>proxy=self._proxy)<EOL><DEDENT>except (errors.OperationFailed, errors.Unsupported):<EOL><INDENT>return idstr_list  <EOL><DEDENT><DEDENT>if h_session.has_children(cat_id):<EOL><INDENT>for child_id in h_session.get_children(cat_id):<EOL><INDENT>idstr_list += self._get_descendent_cat_idstrs(child_id, h_session)<EOL><DEDENT><DEDENT>return list(set(idstr_list))<EOL><DEDENT>use_caching = False<EOL>try:<EOL><INDENT>config = self._runtime.get_configuration()<EOL>parameter_id = Id('<STR_LIT>')<EOL>if config.get_value_by_parameter(parameter_id).get_boolean_value():<EOL><INDENT>use_caching = True<EOL><DEDENT>else:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>except (AttributeError, KeyError, errors.NotFound):<EOL><INDENT>pass<EOL><DEDENT>if use_caching:<EOL><INDENT>key = '<STR_LIT>'.format(str(cat_id))<EOL>caching_engine = '<STR_LIT>'<EOL>try:<EOL><INDENT>config = self._runtime.get_configuration()<EOL>parameter_id = Id('<STR_LIT>')<EOL>caching_engine = config.get_value_by_parameter(parameter_id).get_string_value()<EOL><DEDENT>except (AttributeError, KeyError, errors.NotFound):<EOL><INDENT>pass<EOL><DEDENT>if caching_engine == '<STR_LIT>':<EOL><INDENT>import memcache<EOL>caching_host = '<STR_LIT>'<EOL>try:<EOL><INDENT>config = self._runtime.get_configuration()<EOL>parameter_id = Id('<STR_LIT>')<EOL>caching_host = config.get_value_by_parameter(parameter_id).get_string_value()<EOL><DEDENT>except (AttributeError, KeyError, errors.NotFound):<EOL><INDENT>pass<EOL><DEDENT>mc = memcache.Client([caching_host], debug=<NUM_LIT:0>)<EOL>catalog_ids = mc.get(key)<EOL>if catalog_ids is None:<EOL><INDENT>catalog_ids = get_descendent_ids(hierarchy_session)<EOL>mc.set(key, catalog_ids)<EOL><DEDENT><DEDENT>elif caching_engine == '<STR_LIT>':<EOL><INDENT>import diskcache<EOL>with diskcache.Cache('<STR_LIT>') as cache:<EOL><INDENT>catalog_ids = cache.get(key)<EOL>if catalog_ids is None:<EOL><INDENT>catalog_ids = get_descendent_ids(hierarchy_session)<EOL>cache.set(key, catalog_ids)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>raise errors.NotFound('<STR_LIT>'.format(caching_engine))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>catalog_ids = get_descendent_ids(hierarchy_session)<EOL><DEDENT>return catalog_ids<EOL>
Recursively returns a list of all descendent catalog ids, inclusive