def request_is_live_tween_factory(handler, registry):
    """
    Tween that adds ``LIVE_REQUEST`` to the request's environment, used to
    determine ``request.is_live``.

    .. note::

        This should be added as close as possible to
        :data:`pyramid.tweens.INGRESS` so that ``request.is_live`` can be used
        in other tweens.
    """

    def request_is_live_tween(request):
        request.environ["LIVE_REQUEST"] = True
        return handler(request)

    return request_is_live_tween