def object_insert(self, author, recipient, object_type, obj, session):
        # Handle answer
        obj_class = globals()[object_type]
        missing_keys = obj_class.validate_changeset(obj)
        if len(missing_keys) > 0:
            raise KeyError("Missing '{}' for creating {} from changeset".format(
                ", ".join(missing_keys), obj_class.__name__))

        if hasattr(obj, "author_id") and author.id != obj["author_id"]:
            raise UnauthorizedError(
                "Received object_insert Vesicle author {} does not match object author [{}]".format(
                    author, obj["author_id"][:6]))

        o = obj_class.query.get(obj["id"])
        if o is None or (hasattr(o, "get_state") and o.get_state() == -1) or (isinstance(o, Persona) and o._stub is True):
            o = obj_class.create_from_changeset(obj, stub=o, update_sender=author, update_recipient=recipient)
            session.add(o)
            if isinstance(o, Persona):
                o.stub = False
            else:
                o.set_state(0)
            self.logger.info("Inserted new {}".format(o))

        return o
dataset/ETHPy150Open ciex/souma/synapse/__init__.py/Synapse.object_insert/original