Convert DingoObjDict to facts and associate resulting facts with this information object.

def from_dict(self,
                  dingos_obj_dict,
                  config_hooks=None,
                  namespace_dict=None,
                  ):
        """
        Convert DingoObjDict to facts and associate resulting facts with this information object.
        """


        # Instantiate default parameters




        if '@@ns' in dingos_obj_dict.keys():
            top_level_namespace = (namespace_dict.get(dingos_obj_dict.get('@@ns'),None),dingos_obj_dict.get('@@ns'))
        else:
            top_level_namespace = (None,None)

        if not config_hooks:
            config_hooks = {}

        datatype_extractor = config_hooks.get('datatype_extractor', (lambda io, f, i, n, d: False))

        special_ft_handler = config_hooks.get('special_ft_handler', None)

        attr_ignore_predicate = config_hooks.get('attr_ignore_predicate', None)

        force_nonleaf_fact_predicate = config_hooks.get('force_nonleaf_fact_predicate', None)

        if not namespace_dict:
            namespace_dict = {}


        namespace_uri_2_pk_mapping = dict(self._DCM['DataTypeNameSpace'].objects.values_list('uri','id'))


        if not self.is_empty():
            logger.debug("Non-empty info object %s (timestamp %s, pk %s ) is overwritten with new information" % (self.identifier,
                                                                                                                 self.timestamp,
                                                                                                                 self.pk))
            self.clear()


        # Flatten the DingoObjDict

        (flat_list, attrs) = dingos_obj_dict.flatten(attr_ignore_predicate=attr_ignore_predicate,
                                                     force_nonleaf_fact_predicate=force_nonleaf_fact_predicate,
                                                     namespace_dict=namespace_dict)



        for fact in flat_list:

            # Collect the information about all attributes relevant
            # for this node (i.e., they occur either directly on
            # the node or on an ancestor node).

            # The following code was used to generate a attribute dictionary::
            #
            #     attr_info = ExtendedSortedDict()
            #     for attr_node in attrs.keys():
            #         if fact['node_id'].startswith(attr_node):
            #            for (key, value) in attrs[attr_node].items():
            #                attr_info.chained_set(value, 'set', key, attr_node)
            #
            # The dictionary contained full information about also the attributes given
            # to ancestor nodes. So far, we have not required this
            # information for our imports, and thus simplify to a
            # dictionary that only contains the attributes directly
            # associated with the current node.
            #
            # If, at a later stage, we find we need this kind of information,
            # we will can use Django's MultiValueDict to add additional
            # information without changing the signature of the receiving
            # predicate and handler functions.


            attr_info = dict(attrs.get(fact['node_id'],[]))

            #for attr_node in attrs.keys():
            #    if fact['node_id'] == (attr_node):
            #        for (key, value) in attrs[attr_node].items():
            #            attr_info.chained_set(value, 'set', key, attr_node)


            # Fill dictionary with arguments for call to 'add_fact'

            add_fact_kargs = {}
            add_fact_kargs['fact_dt_kind'] = FactDataType.UNKNOWN_KIND
            add_fact_kargs['fact_dt_namespace_name'] = "%s-%s" % (
                self.iobject_family.name, self.iobject_family_revision.name)

            # See whether the datatype extractor has found a datatype for the value

            datatype_found = datatype_extractor(self, fact, attr_info, namespace_dict, add_fact_kargs)

            if not datatype_found:
                add_fact_kargs = {}
                add_fact_kargs['fact_dt_kind'] = FactDataType.NO_VOCAB
                add_fact_kargs['fact_dt_namespace_name'] = DINGOS_NAMESPACE_SLUG
                add_fact_kargs['fact_dt_namespace_uri'] = DINGOS_NAMESPACE_URI
            else:
                # Check whether the datatype extractor added namespace information
                # If not, add some here
                if not 'fact_dt_namespace_uri' in add_fact_kargs:
                    add_fact_kargs['fact_dt_namespace_uri'] = namespace_dict.get(
                        add_fact_kargs['fact_dt_namespace_name'], '%s/%s' % (
                            DINGOS_NAMESPACE_URI, self.iobject_family))

            add_fact_kargs['fact_term_name'] = fact['term']
            add_fact_kargs['fact_term_attribute'] = fact['attribute']
            add_fact_kargs['values'] = [fact['value']]
            add_fact_kargs['node_id_name'] = fact['node_id']
            add_fact_kargs['namespaces'] = fact['namespaces']
            add_fact_kargs['top_level_namespace'] = top_level_namespace

            handler_return_value = True

            logger.debug("Treating fact (before special handler list) %s with attr_info %s and kargs %s" % (fact, attr_info, add_fact_kargs))
            # Below, go through the handlers in the special_ft_handler list --
            # if the predicate returns True for the fact, execute the handler
            # on the fact. If a handler returns False/None, the fact is *not*
            # added. This should only be done, if the handler has added the
            # fact -- otherwise the sequence of node identifiers is messed up!

            if special_ft_handler:
                for (predicate, handler) in special_ft_handler:
                    if predicate(fact, attr_info):
                        handler_return_value = handler(self, fact, attr_info, add_fact_kargs)
                        if not handler_return_value:
                            break
            logger.debug("Treating fact (before special handler list) %s with attr_info %s and kargs %s" % (fact, attr_info, add_fact_kargs))
            if (handler_return_value == True):
                add_fact_kargs['ns_uri_dict'] = namespace_uri_2_pk_mapping
                e2f_obj = self.add_fact(**add_fact_kargs)
            elif not handler_return_value:
                continue
            else:
                e2f_obj = handler_return_value
        self.set_name()