Jay Parlar wrote:

>What I'd like is that if the client closes their browser,
>some exception gets raised, and I can cancel the rest of the process
>on the server side.
>  
>
Ah... This is interesting :-). A web server will know that a client has 
been disconnected only when it will try to send it something. So if you 
have a long working view you can't know if it works for nothing until it 
finishes.

It's good when you can do calculations and push results to the client 
iteratively. Then you can create an iterator and pass it to a 
HttpResponse. It then will call your code until it's done or an error 
writing data to the client occured. It looks like this:

    def long_process():
      while not done:
        data_chunk = calculate_data_chunk()
        yield data_chunk
       
       
    def some_view(request):
      return HttpResponse(long_process())

P.S. In mod_python you can actually catch the write error in Dango's 
core/handlers/modpython.py because the loop iterating over response's 
iterator is there in 'populate_apache_response'. However in general case 
(WSGI) it's outside of Django and is not accessible.

--~--~---------~--~----~------------~-------~--~----~
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