2012-10-28 05:12:08 +08:00
|
|
|
from django.conf import settings
|
2012-10-27 17:49:46 +08:00
|
|
|
from django.core.management.base import NoArgsCommand
|
2012-10-28 05:12:08 +08:00
|
|
|
from django.utils.importlib import import_module
|
|
|
|
|
2012-10-27 17:49:46 +08:00
|
|
|
|
|
|
|
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):
|
2012-10-28 05:12:08 +08:00
|
|
|
engine = import_module(settings.SESSION_ENGINE)
|
|
|
|
try:
|
|
|
|
engine.SessionStore.clear_expired()
|
|
|
|
except NotImplementedError:
|
|
|
|
self.stderr.write("Session engine '%s' doesn't support clearing "
|
|
|
|
"expired sessions.\n" % settings.SESSION_ENGINE)
|