Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #4427 -- Ported daily_cleanup.py to use model API for greater

portability. Thanks, nick.lane.au@gmail.com.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@5403 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 250b84dd0e30ae916e2f033790098281dff0b9e2 1 parent a3b6e4e
Malcolm Tredinnick authored June 01, 2007
1  AUTHORS
@@ -142,6 +142,7 @@ answer newbie questions, and generally made Django that much better:
142 142
     Joseph Kocherhans
143 143
     konrad@gwu.edu
144 144
     lakin.wecker@gmail.com
  145
+    Nick Lane <nick.lane.au@gmail.com>
145 146
     Stuart Langridge <http://www.kryogenix.org/>
146 147
     Nicola Larosa <nico@teknico.net>
147 148
     Eugene Lazutkin <http://lazutkin.com/blog/>
10  django/bin/daily_cleanup.py
@@ -7,13 +7,13 @@
7 7
 sessions at the moment).
8 8
 """
9 9
 
10  
-from django.db import backend, connection, transaction
  10
+import datetime
  11
+from django.db import transaction
  12
+from django.contrib.sessions.models import Session
11 13
 
12 14
 def clean_up():
13  
-    # Clean up old database records
14  
-    cursor = connection.cursor()
15  
-    cursor.execute("DELETE FROM %s WHERE %s < NOW()" % \
16  
-        (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()
17 17
     transaction.commit_unless_managed()
18 18
 
19 19
 if __name__ == "__main__":

0 notes on commit 250b84d

Please sign in to comment.
Something went wrong with that request. Please try again.