def stream(func):

    @wraps(func)
    def wrapped(request, *args, **kwargs):
        # Set a bit of state for the request.
        request._writer = _stream_output
        _init(request)

        # Create the generator.
        try:
            request._gen = gen = func(request, *args, **kwargs)
        except Exception:
            _cleanup(request)
            raise

        # If we've not got a generator, return the output.
        if not isinstance(gen, GeneratorType):
            _cleanup(request)
            return gen

        # Set a flag on the request so Application won't finish processing it.
        request.auto_finish = False

        # Now let's run the generator for the first time. No input yet, for
        # obvious reasons.
        _do(request, None)

    return wrapped
Return the entire formatted message as a string.
dataset/ETHPy150Open ecdavis/pants/pants/web/asynchronous.py/stream--crossover with--dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.5/django/core/mail/message.py/SafeMIMEMultipart.as_string