2007-01-03 04:39:30 +08:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2006-09-26 21:08:16 +08:00
|
|
|
"""
|
|
|
|
Daily cleanup job.
|
2005-07-13 09:25:57 +08:00
|
|
|
|
2006-09-26 21:08:16 +08:00
|
|
|
Can be run as a cronjob to clean out old data from the database (only expired
|
|
|
|
sessions at the moment).
|
|
|
|
"""
|
2005-07-13 09:25:57 +08:00
|
|
|
|
2007-06-01 17:46:56 +08:00
|
|
|
import datetime
|
|
|
|
from django.db import transaction
|
|
|
|
from django.contrib.sessions.models import Session
|
2005-07-13 09:25:57 +08:00
|
|
|
|
|
|
|
def clean_up():
|
2007-06-01 17:46:56 +08:00
|
|
|
"""Clean up expired sessions."""
|
|
|
|
Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete()
|
2006-05-02 09:31:56 +08:00
|
|
|
transaction.commit_unless_managed()
|
2005-07-13 09:25:57 +08:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
clean_up()
|