- Timestamp:
- 06/17/07 17:18:54 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/per-object-permissions/django/bin/daily_cleanup.py
- Property svn:eol-style set to native
r3940 r5488 1 #!/usr/bin/env python 2 1 3 """ 2 4 Daily cleanup job. … … 6 8 """ 7 9 8 from django.db import backend, connection, transaction 10 import datetime 11 from django.db import transaction 12 from django.contrib.sessions.models import Session 9 13 10 14 def clean_up(): 11 # Clean up old database records 12 cursor = connection.cursor() 13 cursor.execute("DELETE FROM %s WHERE %s < NOW()" % \ 14 (backend.quote_name('django_session'), backend.quote_name('expire_date'))) 15 """Clean up expired sessions.""" 16 Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete() 15 17 transaction.commit_unless_managed() 16 18
