def _get_or_create_moderated_object(self, instance,
                                        unchanged_obj, moderator):
        """
        Get or create ModeratedObject instance.
        If moderated object is not equal instance then serialize unchanged
        in moderated object in order to use it later in post_save_handler
        """
        def get_new_instance(unchanged_obj):
            moderated_object = ModeratedObject(content_object=unchanged_obj)
            moderated_object.changed_object = unchanged_obj
            return moderated_object

        try:
            # if moderator.keep_history:
            #     moderated_object = get_new_instance(unchanged_obj)
            # else:
            #     moderated_object = ModeratedObject.objects.\
            #         get_for_instance(instance)

            moderated_object = ModeratedObject.objects.get_for_instance(
                instance)
            if moderated_object is None:
                moderated_object = get_new_instance(unchanged_obj)
            elif moderator.keep_history and \
                    moderated_object.has_object_been_changed(
                    instance):
                # We're keeping history and this isn't an update of an existing
                # moderation
                moderated_object = get_new_instance(unchanged_obj)

        except __HOLE__:
            moderated_object = get_new_instance(unchanged_obj)

        else:
            if moderated_object.has_object_been_changed(instance):
                if moderator.visible_until_rejected:
                    moderated_object.changed_object = instance
                else:
                    moderated_object.changed_object = unchanged_obj

        return moderated_object
dataset/ETHPy150Open dominno/django-moderation/moderation/register.py/ModerationManager._get_or_create_moderated_object