def obj_change_as_msg(self, obj, msg, meteor_ids=None):
        """Return DDP change message of specified type (msg) for obj."""
        if meteor_ids is None:
            meteor_ids = {}
        try:
            meteor_id = meteor_ids[str(obj.pk)]
        except __HOLE__:
            meteor_id = None
        if meteor_id is None:
            meteor_ids[str(obj.pk)] = meteor_id = get_meteor_id(obj)
        assert meteor_id is not None
        if msg == REMOVED:
            data = {}  # `removed` only needs ID (added below)
        elif msg in (ADDED, CHANGED):
            data = self.serialize(obj, meteor_ids)
        else:
            raise ValueError('Invalid message type: %r' % msg)

        data.update(msg=msg, collection=self.name, id=meteor_id)
        return data
dataset/ETHPy150Open django-ddp/django-ddp/dddp/api.py/Collection.obj_change_as_msg