On Mon, 2006-06-26 at 13:28 -0700, Tyson Tate wrote:
> 
> On Jun 26, 2006, at 12:43 PM, Glenn Tenney wrote:
> >
> > [...]
> > 2) Also within your application, write a global function that (a)
> > immediately checks to see if it's the first time it's invoked each day
> > (or whatever interval), and then, if it is the first time, (b) does
> > all of the repetitive tasks...  This translates to: the first click
> > within the desired interval automatically performs the pending
> > repetitive tasks.  Note: this is not always a good solution (but can
> > sometimes be fine), since you might have tasks that need to be done
> > every interval even if no one clicks your site, or the tasks run a
> > long time, etc.  This can be combined with #1 above in that the URL in
> > #1 above would only need to be some regular URL into your application
> > since ANY click to your application will do the repetitive task once
> > each interval. [...]
> 
> I've found a better solution with signals and the dispatcher. The  
> essence is that you raise a signal every time someone views the  
> relevant page, for instance, a "Recent Flickr Photos" page. In the  
> relevant models.py file, you'll have attached a function call to be  
> called on the raising of that signal. That function should check when  
> the last time it was run, if it was run more than X minutes ago, have  
> it call the relevant Flickr synchronization code, or whatever else  
> you want it to do.

Not a good idea if the process takes any significant amount of time to
run (such as, for example, retrieving things of the Internet). It will
block the response back to the user.

Malcolm



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