I'm new to Pythonm, GoogleAppEngine and pretty much webdev in general, so this might be a silly question, but I'm short on time and I can't seem to find anything on the subject. I'm using webapp2 and jinja2 along with Python and GAE.
I have an assignment to make a simple app, where the administrator can post event announcements and the logged users can join them. The thing that I don't know how to implement, is that at a certain time before the event occurs (the admin specifies a date), an email is sent to all the users that joined an event.
My question is: how can I implement a global logic for the app that will check wheter it is the time to send the emails?
The program cron
is a popular UNIX utility for scheduling tasks to occur at predefined intervals.
You can use a "cron job" in your GAE app to implement the functionality you require.
Basically, you define a handler in your app that responds to a GET request and map it to an endpoint like "/cron/send_reminder". Then you make an entry in cron.yaml that instructs the app to call your handler (using an HTTP request) at specified intervals.
Inside your handler, you would need logic to retrieve from the datastore the list of events that have users who haven't been reminded yet. Then you would send your emails and mark those events as done.
The cron script is constantly running in the background, even if the list of events that require reminding is empty.