On Wed, 13 Jun 2001, Etienne Labuschagne wrote:
I know that I can make my long process run in a thread and return immediately, but how do I notify the client browser when the thread have finally finished. Is the only way to write a self-reloading page as response for the client so that his browser checks every now and again if the process is finished
There's a solution for that, I've used it in a CGI script to solve a browser (or Apache) timeout problem when launching long SQL queries, but have not implemented it in Zope, so I don't know how this would apply to Zope. you have to return a document which content-type is: multipart/x-mixed-replace;boundary=XXX where XXX is some random string. the first line of you document must contain: --XXX (same XXX as before) then you launch a thread which periodically send a normal CGI document (with headers, and content-type=text/html for example) displaying for example the elapsed time since you've begun to convert files, but this document must end with "\n--%s" % XXX (still same XXX as above) then you start to convert files. During the conversion your thread will periodically send a new page to your browser, so you can display in it as many info as you want: elapsed time, number of converted files, etc... when it's finished you end the thread. then you finish the enclosing CGI document which content type is multipart/x-mixed-replace, terminating it with: "\n--%s--" % XXX (still same XXX) then it's done. I don't know if this would work at all in Zope, but I suppose you can try this way. Anyway I can send to you my python CGI script if you want. bye, Jerome Alet