def new(self, _def, _dict=None, **kwargs):
        if _def in model_classes:
            clzz = model_classes[_def]
        elif _def in message_classes:
            clzz = message_classes[_def]
        elif _def in enum_classes:
            clzz = enum_classes[_def]
        else:
            raise NotFound("No matching class found for name %s" % _def)

        # Conditionally override the __setattr__ method to include additional client side validation
        # NOTE: currently mandatory because it performs unicode to UTF-8 str conversion as side effect
        if self.validate_setattr:
            def validating_setattr(self, name, value):
                from pyon.core.object import BUILT_IN_ATTRS
                if name not in self._schema and name not in BUILT_IN_ATTRS:
                    raise AttributeError("'%s' object has no attribute '%s'" % (type(self).__name__, name))
                self.__dict__[name] = value
            setattrmethod = validating_setattr
            setattr(clzz, "__setattr__", setattrmethod)

        if _dict:
            # Traverse input parameters looking for dict values being passed in as
            # the init values of complex types.  Instantiate new object and substitute
            # into the argument dict.
            tmpdict = deepcopy(_dict)

            for key in tmpdict:
                if key in clzz._schema:
                    if isinstance(tmpdict[key], dict) and clzz._schema[key]["type"] in model_classes:
                        obj_param = self.new(clzz._schema[key]["type"], tmpdict[key])
                        tmpdict[key] = obj_param
                else:
                    raise AttributeError("'%s' object has no attribute '%s'" % (clzz.__name__, key))

            # Apply dict values, then override with kwargs
            keywordargs = tmpdict
            keywordargs.update(kwargs)
            obj = clzz(**keywordargs)
        else:
            obj = clzz(**kwargs)

        return obj
Instantiates an IonObject based on given object type name and initial values.
dataset/ETHPy150Open ooici/pyon/pyon/core/registry.py/IonObjectRegistry.new