Re: streaming status

2007-11-04 Thread James Bennett

On 11/4/07, Karen Tracey <[EMAIL PROTECTED]> wrote:
> No.  The only way to send stuff to a browser is to respond to an HTTP
> request, so if you want the browser to see regular status updates you'll
> have to set it up so that the browser makes periodic requests for status.
> I've never used this technique but here's a page describing a way to do it
> (along with pros and cons and questioning of do you really want to do this):

Well, you can use chunked transfer and keep sending data over a
long-lived HTTP connection (which is how Comet applications work), but
it's not necessarily a good idea; on most normal server setups you'll
end up with much higher load, and some browsers don't handle it all
that well.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: streaming status

2007-11-04 Thread Ben Ford
I'm not sure about this particular instance, but Templates are iterators I
think so you might be able to come up with somthing if you hack around with
the internals. Sorry I can't be more specific, but I don't have access to my
normal environment at the moment!
Ben



On 04/11/2007, Karen Tracey <[EMAIL PROTECTED]> wrote:
>
> On 11/4/07, Carl Karsten <[EMAIL PROTECTED]> wrote:
> >
> > A view has a loop - each iteration may take 3 seconds, and it will loop
> > 20+
> > times, so 1 min of processing.
> >
> > Is there some way to dump stuff to the browser page each loop?
>
>
> No.  The only way to send stuff to a browser is to respond to an HTTP
> request, so if you want the browser to see regular status updates you'll
> have to set it up so that the browser makes periodic requests for status.
> I've never used this technique but here's a page describing a way to do it
> (along with pros and cons and questioning of do you really want to do this):
>
>
> http://webtips.dan.info/refresh.html
>
> Note that if you do this, the time-consuming processing you currently have
> in your view will have to be moved elsewhere, because the browser sees
> nothing until your view returns an HttpResponse.  Your view will have to
> kick off this other processing in a separate thread or process, and then
> return a response describing status.  When subsequent status requests come
> in, they will have to somehow be able to find out how far along the process
> is...you'll have to work out how to do that, whether by storing status in
> the database or a file or something.
>
> Actually even if you don't do the refresh thing, I think it would make
> sense to move that long-running code out of the view and provide for
> responding to queries on status.  A page that takes a minute to load is
> going to seem broken, even if users know it is supposed to take a long
> time.  In the year since they last ran it they're going to have forgotten
> how long it takes, and despite any warnings to "Click DOIT only once!"
> they're going to go back and click DOIT again
>
> Karen
>
> >
>


-- 
Regards,
Ben Ford
[EMAIL PROTECTED]
+6281317958862

--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: streaming status

2007-11-04 Thread Karen Tracey
On 11/4/07, Carl Karsten <[EMAIL PROTECTED]> wrote:
>
> A view has a loop - each iteration may take 3 seconds, and it will loop
> 20+
> times, so 1 min of processing.
>
> Is there some way to dump stuff to the browser page each loop?


No.  The only way to send stuff to a browser is to respond to an HTTP
request, so if you want the browser to see regular status updates you'll
have to set it up so that the browser makes periodic requests for status.
I've never used this technique but here's a page describing a way to do it
(along with pros and cons and questioning of do you really want to do this):

http://webtips.dan.info/refresh.html

Note that if you do this, the time-consuming processing you currently have
in your view will have to be moved elsewhere, because the browser sees
nothing until your view returns an HttpResponse.  Your view will have to
kick off this other processing in a separate thread or process, and then
return a response describing status.  When subsequent status requests come
in, they will have to somehow be able to find out how far along the process
is...you'll have to work out how to do that, whether by storing status in
the database or a file or something.

Actually even if you don't do the refresh thing, I think it would make sense
to move that long-running code out of the view and provide for responding to
queries on status.  A page that takes a minute to load is going to seem
broken, even if users know it is supposed to take a long time.  In the year
since they last ran it they're going to have forgotten how long it takes,
and despite any warnings to "Click DOIT only once!" they're going to go back
and click DOIT again

Karen

--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



streaming status

2007-11-04 Thread Carl Karsten

A view has a loop - each iteration may take 3 seconds, and it will loop 20+ 
times, so 1 min of processing.

Is there some way to dump stuff to the browser page each loop?

Right now I am printing to the console, which is fine, but not cool.  It's more 
for testing, wich will happen 100's of times, then the thing will get used in 
production once a year.

Carl K



--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---