I have two thoughts on how you could do this. 1) You could just have some client side javascript which displays a progress bar that just guesses but never gets any feedback from the server. Any unexpected jump at the end makes it look like it took less time than expected. Works great as long as the process doesn't run unusually long. For that matter a simple message that the user needs to wait for 15 seconds or more may be as effective.
2) Split the entire process into multiple processes so that each stage will not happen until an ajax request is recieved requesting it. You no longer have to worry about getting the correct thread, just that you are using the correct file(s) stored on the server which should be easily tracked via sessions/cookies: 1. Upload the file, save to disk and return success 2. Send ajax request to 'generate' (result stored on server) and return success 3. Send ajax request to 'compile' (result stored on server) and return success 4. Send ajax request to download result Of course, at each stage your progress bar could easily be updated. On 6/2/06, Jay Parlar <[EMAIL PROTECTED]> wrote: > > The main view of my internal web app is a form with an upload field, > and when the user uploads a file, my server-side processing takes > about 15 seconds to complete (I generate and then compile some stuff > based on the file they upload, and return the compiled result) > > From the user's POV, it just looks like it takes 15 seconds for the > next page to load after pressing "Submit". > > Because it's an internal app, that's technically ok, but I'd like > something a bit nicer. I think it'd be helpful to have a small div on > the page constantly updating with the progress of the server side > work, after they press Submit. > > What I'm thinking, is doing an XMLHTTPRequest after they press Submit. > The first response would be something like "Beginning generation", > which I'd update onto the page. Then I'd send out another > XMLHTTPRequest, who's eventual response will be "Generation done, > beginning compile". Etc etc etc. > > The thing is, I'm not sure how to fit that into Django. Currently, my > view function just blocks on the generation/compilation. To do this > with AJAX, it feels like I'd have to spawn a thread from Django to do > the processing, and let the view return immediately. But when the > resulting page does the first XMLHTTPRequest, how can I guarantee that > it'll hit the same mod_python interpreter that's running my thread? > > Is that even a good thing to do with mod_python? > > Any suggestions would be greatly appreciated. I've only done a little > bit of playing around with AJAX technologies so far, and I've never > used Apache+mod_python before, so there are a lot of unknowns for me. > I also haven't tried out the Session middleware yet, so I don't know > how helpful that will be. > > Thanks, > Jay P. > > > > -- ---- Waylan Limberg [EMAIL PROTECTED] --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---