Ticket #18978: 18978.patch

File 18978.patch, 6.1 KB (added by Aymeric Augustin, 12 years ago)
  • django/bin/daily_cleanup.py

    commit ab42a160f7f51f4fcfee65c1078e40c57104e042
    Author: Aymeric Augustin <aymeric.augustin@m4x.org>
    Date:   Sat Oct 27 11:49:46 2012 +0200
    
        Fixed #18978 -- Moved cleanup command to sessions.
        
        This removes a dependency of 'core' on 'contrib'.
    
    diff --git a/django/bin/daily_cleanup.py b/django/bin/daily_cleanup.py
    index c9f4cb9..ac3de00 100755
    a b Can be run as a cronjob to clean out old data from the database (only expired  
    77sessions at the moment).
    88"""
    99
     10import warnings
     11
    1012from django.core import management
    1113
    1214if __name__ == "__main__":
    13     management.call_command('cleanup')
     15    warnings.warn(
     16        "The `daily_cleanup` script has been deprecated "
     17        "in favor of `django-admin.py clearsessions`.",
     18        PendingDeprecationWarning)
     19    management.call_command('clearsessions')
  • new file django/contrib/sessions/management/commands/clearsessions.py

    diff --git a/django/contrib/sessions/management/__init__.py b/django/contrib/sessions/management/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/contrib/sessions/management/commands/__init__.py b/django/contrib/sessions/management/commands/__init__.py
    new file mode 100644
    index 0000000..e69de29
    diff --git a/django/contrib/sessions/management/commands/clearsessions.py b/django/contrib/sessions/management/commands/clearsessions.py
    new file mode 100644
    index 0000000..fb7666f
    - +  
     1from django.core.management.base import NoArgsCommand
     2from django.utils import timezone
     3
     4class Command(NoArgsCommand):
     5    help = "Can be run as a cronjob or directly to clean out expired sessions (only with the database backend at the moment)."
     6
     7    def handle_noargs(self, **options):
     8        from django.db import transaction
     9        from django.contrib.sessions.models import Session
     10        Session.objects.filter(expire_date__lt=timezone.now()).delete()
     11        transaction.commit_unless_managed()
  • django/core/management/commands/cleanup.py

    diff --git a/django/core/management/commands/cleanup.py b/django/core/management/commands/cleanup.py
    index e19d164..f83c64b 100644
    a b  
    1 from django.core.management.base import NoArgsCommand
    2 from django.utils import timezone
     1import warnings
    32
    4 class Command(NoArgsCommand):
    5     help = "Can be run as a cronjob or directly to clean out old data from the database (only expired sessions at the moment)."
     3from django.contrib.sessions.management.commands import clearsessions
    64
     5
     6class Command(clearsessions.Command):
    77    def handle_noargs(self, **options):
    8         from django.db import transaction
    9         from django.contrib.sessions.models import Session
    10         Session.objects.filter(expire_date__lt=timezone.now()).delete()
    11         transaction.commit_unless_managed()
     8        warnings.warn(
     9            "The `cleanup` command has been deprecated in favor of `clearsessions`.",
     10            PendingDeprecationWarning)
     11        super(Command, self).handle_noargs(**options)
  • docs/internals/deprecation.txt

    diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt
    index 10bbfe1..77371c8 100644
    a b these changes.  
    293293* The ``AUTH_PROFILE_MODULE`` setting, and the ``get_profile()`` method on
    294294  the User model, will be removed.
    295295
     296* The ``cleanup`` management command will be removed. It's replaced by
     297  ``clearsessions``.
     298
     299* The ``daily_cleanup.py`` script will be removed.
     300
    2963012.0
    297302---
    298303
  • docs/ref/django-admin.txt

    diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt
    index 7fa7539..833db08 100644
    a b cleanup  
    9696Can be run as a cronjob or directly to clean out old data from the database
    9797(only expired sessions at the moment).
    9898
     99.. versionchanged:: 1.5
     100    :djadmin:`cleanup` is deprecated. Use :djadmin:`clearsessions` instead.
     101
    99102compilemessages
    100103---------------
    101104
    This command is only available if :doc:`GeoDjango </ref/contrib/gis/index>`  
    11871190Please refer to its :djadmin:`description <ogrinspect>` in the GeoDjango
    11881191documentation.
    11891192
     1193``django.contrib.sessions``
     1194---------------------------
     1195
     1196clearsessions
     1197~~~~~~~~~~~~~~~
     1198
     1199.. django-admin:: clearsessions
     1200
     1201Can be run as a cron job or directly to clean out expired sessions.
     1202
     1203This is only supported by the database backend at the moment.
     1204
    11901205``django.contrib.sitemaps``
    11911206---------------------------
    11921207
  • docs/releases/1.5.txt

    diff --git a/docs/releases/1.5.txt b/docs/releases/1.5.txt
    index a0ce3cc..ebf88e8 100644
    a b Define a ``__str__`` method and apply the  
    613613The :func:`~django.utils.itercompat.product` function has been deprecated. Use
    614614the built-in :func:`itertools.product` instead.
    615615
    616 
    617616``django.utils.markup``
    618617~~~~~~~~~~~~~~~~~~~~~~~
    619618
    The markup contrib module has been deprecated and will follow an accelerated  
    621620deprecation schedule. Direct use of python markup libraries or 3rd party tag
    622621libraries is preferred to Django maintaining this functionality in the
    623622framework.
     623
     624``cleanup`` management command
     625~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     626
     627The :djadmin:`cleanup` management command has been deprecated and replaced by
     628:djadmin:`clearsessions`.
     629
     630``daily_cleanup.py`` script
     631~~~~~~~~~~~~~~~~~~~~~~~~~~~
     632
     633The undocumented ``daily_cleanup.py`` script has been deprecated. Use the
     634:djadmin:`clearsessions` management command instead.
  • docs/topics/http/sessions.txt

    diff --git a/docs/topics/http/sessions.txt b/docs/topics/http/sessions.txt
    index 15f9f7f..0082b75 100644
    a b table. Django updates this row each time the session data changes. If the user  
    460460logs out manually, Django deletes the row. But if the user does *not* log out,
    461461the row never gets deleted.
    462462
    463 Django provides a sample clean-up script: ``django-admin.py cleanup``.
     463Django provides a sample clean-up script: ``django-admin.py clearsessions``.
    464464That script deletes any session in the session table whose ``expire_date`` is
    465465in the past -- but your application may have different requirements.
    466466
Back to Top