Martin,

Cool, this actually works with yielding, thank you very much.

You don't seem to be THAT new too django:)

Kind Regards,

Nick Parrin

On 7/15/06, Martin Glueck <[EMAIL PROTECTED]> wrote:

Nick,

I'm new to Django so if I'm wrong here, I hope that somebody will
correct me.....
> I'm wondering, is it possible in django to write out data to the client
> (maybe via HttpResponse?) in an ubuffered way, so that you feed the data as
> it comes in django to the end user. I figured it's not possible because you
> need to return the HttpResponse object for the client to get data.
>
Yes, but you can pass a `iterable` object as the content.
So, I would write a generator-function and pass this as the content to
the Response object:

def lazy_content (obj = ....) :
    for line in obj.... :
        yield line
# end def lazy_content

And during the creation of the Response object you should `call` this
generator funtion:

  return http.HttpResponse (lazy_content (my_obj))


In thus case, the generator `exetuted` after the headers have been send
and all the lines you yield will be directly send to stdout. Maybe you
have to flush stdout to be really unbuffered...

I hope this helps (sorry for my bad english, ....)


Martin



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to