bgneal@513: """ bgneal@513: Celery tasks for the core application. bgneal@513: bgneal@513: """ bgneal@513: from celery.task import task bgneal@513: import django.core.mail bgneal@513: bgneal@513: bgneal@513: @task bgneal@513: def add(x, y): bgneal@516: """ bgneal@516: It is useful to have a test task laying around. This is it. bgneal@516: bgneal@516: """ bgneal@513: return x + y bgneal@513: bgneal@516: bgneal@513: @task bgneal@513: def send_mail(subject, message, from_email, recipient_list, **kwargs): bgneal@516: """ bgneal@516: A task to send mail via Django. bgneal@516: bgneal@516: """ bgneal@513: django.core.mail.send_mail(subject, message, from_email, recipient_list, bgneal@513: **kwargs) bgneal@516: bgneal@516: bgneal@516: @task bgneal@516: def cleanup(): bgneal@516: """ bgneal@516: A task to perform site-wide cleanup actions. bgneal@516: bgneal@516: """ bgneal@518: # These imports, when placed at the top of the module, caused all kinds of bgneal@518: # import problems when running on the production server (Python 2.5 and bgneal@518: # mod_wsgi). Moving them here worked around that problem. bgneal@518: bgneal@517: from django.core.management.commands.cleanup import Command as CleanupCommand bgneal@517: from forums.management.commands.forum_cleanup import Command as ForumCleanup bgneal@518: bgneal@516: # Execute Django's cleanup command (deletes old sessions). bgneal@516: bgneal@516: command = CleanupCommand() bgneal@516: command.execute() bgneal@516: bgneal@516: # Execute our forum cleanup command to delete old last visit records. bgneal@516: bgneal@516: command = ForumCleanup() bgneal@516: command.execute()