Revision 5e1ea6f7 snf-astakos-app/astakos/im/management/commands/cleanup-full.py
b/snf-astakos-app/astakos/im/management/commands/cleanup-full.py | ||
---|---|---|
1 |
# Copyright 2012 GRNET S.A. All rights reserved. |
|
1 |
# Copyright 2012, 2013 GRNET S.A. All rights reserved.
|
|
2 | 2 |
# |
3 | 3 |
# Redistribution and use in source and binary forms, with or |
4 | 4 |
# without modification, are permitted provided that the following |
... | ... | |
39 | 39 |
|
40 | 40 |
from astakos.im.models import SessionCatalog |
41 | 41 |
|
42 |
|
|
42 | 43 |
class Command(NoArgsCommand): |
44 |
help = "Cleanup sessions and session catalog" |
|
45 |
|
|
43 | 46 |
def handle_noargs(self, **options): |
44 | 47 |
self.stdout.write('Cleanup sessions ...\n') |
45 | 48 |
call_command('cleanup') |
... | ... | |
47 | 50 |
self.stdout.write('Cleanup session catalog ...\n') |
48 | 51 |
engine = import_module(settings.SESSION_ENGINE) |
49 | 52 |
store = engine.SessionStore() |
50 |
tbd = (entry for entry in SessionCatalog.objects.all() \
|
|
51 |
if not store.exists(entry.session_key)) |
|
53 |
tbd = (entry for entry in SessionCatalog.objects.all() |
|
54 |
if not store.exists(entry.session_key))
|
|
52 | 55 |
for entry in tbd: |
53 | 56 |
entry.delete() |
Also available in: Unified diff