<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I need a little help. Anytime I find myself walking off the well worn path I have to ask myself "I bet someone has been here before.... let me see what they did in this situation."<div><br></div><div>I have a program pattern that goes something like this:</div><div><br></div><div>1) Special event occurs, causing a page to be loaded, and therefore Django to process an event.</div><div>2) The initial processing is executed very quick/simple</div><div>3) Depending upon step 2, a different Python routine will be executed (maybe not even in Django/Maybe as a subprocess)</div><div>4) The page is displayed to the user who triggered the event in step 1.</div><div>5) User can click a 'link' in the page displayed in step 4 to check on status of event triggered</div><div>6) If the process has not completed, this new page will indicate this; User can reclick and go to step 5. If it has, the new page will be the results of that process. The process is complete.</div><div><br></div><div>Now, thus far, timing has not been an issue - but I've not tested under a heavy load, so I'm sure it will be over time. Steps 1, 2 and 4 can be done in very reasonable time and the user sees no real delay.</div><div><br></div><div>I have two [now 3] approaches I am considering, but both feel very hackish....</div><div><br></div><div>Approach #1</div><div>-----------------</div><div>a. In step 2 above, a guaranteed unique new static page is generated (e.g., 534d423d.html). The contents of this page is "Not complete. Click to check again." The link is the page itself (e.g., 534d423d.html)</div><div>b. Whenever the Python routine in step 3 is complete, it replaces the page (i.e., 534d423d.html) with the results data information and the process is over</div><div><br></div><div>The strength of this approach is that we're now only dealing with static pages. Efficiency is high. And the process is simple.</div><div>The&nbsp;weakness&nbsp;of this approach is that there's no way to clean up these 'unique' pages except at a later time (by comparing timestamps from when the file was created). I see capacity planning problems with this.</div><div><br></div><div>Approach #2</div><div>------------------</div><div>A similar approach but with dynamically created urls for this guaranteed uniqueness. I don't know how this can be done truly dynamically since urls.py is not something we want to reinterpret each time. The more I think about the strengths and weaknesses of this approach, the less I see a benefit of doing it this way. I also predict Django will not play nicely with me when I step outside 'the box' with this one.</div><div><br></div><div>Approach #3 (Discovered right before sending)</div><div>-----------------</div><div>[Doh! Ajax would be a very simple solution here.]</div><div><br></div><div><br></div><div><br></div><div>This seems to be a fairly common 'cycle' in web programming. I've seen the pattern many times before in clumsier days with clumsier tools. Does this have a name? Is there any standard approach anyone takes? Best yet, is there a python module already out there that someone knows about that facilities and manages approach #1? &nbsp;Is there a third &nbsp;approach I hadn't considered? &nbsp;[DOH! Just before sending this, I hit myself in the&nbsp;forehead&nbsp;and think of an Ajax approach]. I *must* have this disconnect at step 3 because I cannot guarantee any timely response from the routine to be executed. In fact, some of these routines will be written by others in the future... it's a configurable system where the routine can be plugged in via an API.</div><div><br></div><div>You've already been helpful for being a sounding board comparing these approaches.&nbsp;</div><div><br></div><div>Cheers,</div><div><br></div><div><br></div><div>Glen</div><div><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">--</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">415-680-3964</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><a href="mailto:glen@glenjarvis.com">glen@glenjarvis.com</a></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; min-height: 14px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">"You must be the change you wish to see in the world." -M. Gandhi</div></div></div></div></div></div></span> </div><br></div></body></html>