def _init_from_dictionary(self, from_dictionary, template_model=None):
if not isinstance(from_dictionary, dict):<EOL><INDENT>raise TypeError("<STR_LIT>" % from_dictionary.__class__.__name__)<EOL><DEDENT>rewrite_map = None<EOL>if template_model is not None:<EOL><INDENT>if not isinstance(template_model, DataCollection):<EOL><INDENT>msg = "<STR_LIT>" % template_model.__class__.__name__<EOL>raise TypeError(msg)<EOL><DEDENT>rewrite_map = template_model.attribute_rewrite_reverse_map()<EOL><DEDENT>for key, value in iter(from_dictionary.items()):<EOL><INDENT>target_key = key<EOL>if rewrite_map is not None:<EOL><INDENT>target_key = rewrite_map[key]<EOL><DEDENT>if template_model is not None and target_key not in template_model:<EOL><INDENT>unwanted_keys = list()<EOL>unwanted_keys.append(target_key)<EOL>raise exception.AttributeFilterDiffers(unwanted_keys)<EOL><DEDENT>if not isinstance(value, (bool, dict)):<EOL><INDENT>raise TypeError("<STR_LIT>" % (key, value.__class__.__name__))<EOL><DEDENT>if isinstance(value, bool):<EOL><INDENT>setattr(self, target_key, value)<EOL><DEDENT>elif isinstance(value, dict):<EOL><INDENT>sub_map = None<EOL>if template_model is not None:<EOL><INDENT>sub_map = getattr(template_model, target_key)<EOL>if isinstance(sub_map, Array):<EOL><INDENT>sub_map = sub_map.element_template<EOL><DEDENT><DEDENT>setattr(self, target_key, AttributeFilter(from_dictionary=value, template_model=sub_map))<EOL><DEDENT><DEDENT>
Private helper to init values from a dictionary, wraps children into
AttributeFilter objects

:param from_dictionary: dictionary to get attribute names and visibility from
:type from_dictionary: dict
:param template_model:
:type template_model: DataCollection