我们从Python开源项目中,提取了以下1个代码示例,用于说明如何使用collections.html()。
def _load(self, body, resource, nested_in=None): """Load the composite field. :param body: parent JSON body. :param resource: parent resource. :param nested_in: parent resource name (for error reporting only). :returns: a new object with sub-fields attached to it. """ nested_in = (nested_in or []) + self._path value = super(CompositeField, self)._load(body, resource) if value is None: return None # We need a new instance, as this method is called a singleton instance # that is attached to a class (not instance) of a resource or another # CompositeField. We don't want to end up modifying this instance. instance = copy.copy(self) for attr, field in self._subfields.items(): # Hide the Field object behind the real value setattr(instance, attr, field._load(value, resource, nested_in)) return instance # Satisfy the mapping interface, see # https://docs.python.org/2/library/collections.html#collections.Mapping.