Loading django/bin/daily_cleanup.py +7 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,13 @@ Can be run as a cronjob to clean out old data from the database (only expired sessions at the moment). """ import warnings from django.core import management if __name__ == "__main__": management.call_command('cleanup') warnings.warn( "The `daily_cleanup` script has been deprecated " "in favor of `django-admin.py clearsessions`.", PendingDeprecationWarning) management.call_command('clearsessions') django/contrib/sessions/management/__init__.py 0 → 100644 +0 −0 Empty file added. django/contrib/sessions/management/commands/__init__.py 0 → 100644 +0 −0 Empty file added. django/contrib/sessions/management/commands/clearsessions.py 0 → 100644 +11 −0 Original line number Diff line number Diff line from django.core.management.base import NoArgsCommand from django.utils import timezone class Command(NoArgsCommand): help = "Can be run as a cronjob or directly to clean out expired sessions (only with the database backend at the moment)." def handle_noargs(self, **options): from django.db import transaction from django.contrib.sessions.models import Session Session.objects.filter(expire_date__lt=timezone.now()).delete() transaction.commit_unless_managed() django/core/management/commands/cleanup.py +8 −8 Original line number Diff line number Diff line from django.core.management.base import NoArgsCommand from django.utils import timezone import warnings class Command(NoArgsCommand): help = "Can be run as a cronjob or directly to clean out old data from the database (only expired sessions at the moment)." from django.contrib.sessions.management.commands import clearsessions class Command(clearsessions.Command): def handle_noargs(self, **options): from django.db import transaction from django.contrib.sessions.models import Session Session.objects.filter(expire_date__lt=timezone.now()).delete() transaction.commit_unless_managed() warnings.warn( "The `cleanup` command has been deprecated in favor of `clearsessions`.", PendingDeprecationWarning) super(Command, self).handle_noargs(**options) Loading
django/bin/daily_cleanup.py +7 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,13 @@ Can be run as a cronjob to clean out old data from the database (only expired sessions at the moment). """ import warnings from django.core import management if __name__ == "__main__": management.call_command('cleanup') warnings.warn( "The `daily_cleanup` script has been deprecated " "in favor of `django-admin.py clearsessions`.", PendingDeprecationWarning) management.call_command('clearsessions')
django/contrib/sessions/management/commands/clearsessions.py 0 → 100644 +11 −0 Original line number Diff line number Diff line from django.core.management.base import NoArgsCommand from django.utils import timezone class Command(NoArgsCommand): help = "Can be run as a cronjob or directly to clean out expired sessions (only with the database backend at the moment)." def handle_noargs(self, **options): from django.db import transaction from django.contrib.sessions.models import Session Session.objects.filter(expire_date__lt=timezone.now()).delete() transaction.commit_unless_managed()
django/core/management/commands/cleanup.py +8 −8 Original line number Diff line number Diff line from django.core.management.base import NoArgsCommand from django.utils import timezone import warnings class Command(NoArgsCommand): help = "Can be run as a cronjob or directly to clean out old data from the database (only expired sessions at the moment)." from django.contrib.sessions.management.commands import clearsessions class Command(clearsessions.Command): def handle_noargs(self, **options): from django.db import transaction from django.contrib.sessions.models import Session Session.objects.filter(expire_date__lt=timezone.now()).delete() transaction.commit_unless_managed() warnings.warn( "The `cleanup` command has been deprecated in favor of `clearsessions`.", PendingDeprecationWarning) super(Command, self).handle_noargs(**options)