def extract_name(self):
name = None<EOL>name_schemas = self._DCM["<STR_LIT>"].objects.filter(iobject_type=self.iobject_type).order_by(<EOL>'<STR_LIT>').values_list('<STR_LIT>', flat=True)<EOL>name_components = []<EOL>fact_list = self._DCM['<STR_LIT>'].objects.filter(iobject_thru__iobject=self).order_by(<EOL>'<STR_LIT>').values_list('<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>')<EOL>fact_dict = {}<EOL>counter = <NUM_LIT:0><EOL>for (node_id, fact_term, attribute, value, storage_location, related_obj_name) in fact_list:<EOL><INDENT>if type(value)==type([]):<EOL><INDENT>value = "<STR_LIT>" % value<EOL><DEDENT>if storage_location == dingos.DINGOS_BLOB_TABLE:<EOL><INDENT>try:<EOL><INDENT>value = BlobStorage.objects.get(sha256=value).content<EOL><DEDENT>except:<EOL><INDENT>value = "<STR_LIT>" % value<EOL><DEDENT><DEDENT>elif related_obj_name:<EOL><INDENT>value = related_obj_name<EOL><DEDENT>if attribute:<EOL><INDENT>fact_term = "<STR_LIT>" % (fact_term, attribute)<EOL><DEDENT>if not fact_term in fact_dict:<EOL><INDENT>fact_dict[fact_term] = value<EOL><DEDENT>fact_dict["<STR_LIT>" % node_id] = fact_term<EOL>fact_dict["<STR_LIT>" % node_id] = value<EOL>if counter < <NUM_LIT:10>:<EOL><INDENT>fact_dict["<STR_LIT>" % counter] = fact_term<EOL>fact_dict["<STR_LIT>" % counter] = value<EOL><DEDENT>counter += <NUM_LIT:1><EOL><DEDENT>fact_dict["<STR_LIT>" % counter] = "<STR_LIT>"<EOL>fact_dict["<STR_LIT>"] = "<STR_LIT:%s>" % counter<EOL>name_found = False<EOL>for format_string in name_schemas:<EOL><INDENT>format_string = format_string.replace('<STR_LIT:%>','<STR_LIT>')<EOL>format_string = RE_SEARCH_PLACEHOLDERS.sub("<STR_LIT>", format_string)<EOL>try:<EOL><INDENT>name = format_string % fact_dict<EOL>name_found = True<EOL>break<EOL><DEDENT>except:<EOL><INDENT>continue<EOL><DEDENT><DEDENT>if not name_found:<EOL><INDENT>if self.iobject_type.name == '<STR_LIT>':<EOL><INDENT>return "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>return "<STR_LIT>" % (self.iobject_type.name,counter)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return name<EOL><DEDENT>
We want to dynamically name the iobject based on its type and
selected facts. This is, what this function does: it collects
all facts that have "naming" set and concatenates them in the
order given by the "naming" argument.
If no fact has such a flag, the type is used