Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#2796 closed enhancement (wontfix)

daily_cleanup outdated and hard to access

Reported by: sdistefano Owned by: Adrian Holovaty
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

So I made a patch (first time I'm touching the code, so probably not good enough). It adds a cleanup option to manage.py, which seems more logical to me

here it goes

Index: management.py
===================================================================
--- management.py (révision 3797)
+++ management.py (copie de travail)
@@ -1187,6 +1187,20 @@

test.help_doc = 'Runs the test suite for the specified applications, or the entire site if no apps are specified'
test.args = '[--verbosity] ' + APP_ARGS

+def cleanup():
+ "Runs the daily cleanup job for this site"
+ from django.conf import settings
+ from django.db import backend, connection, transaction
+ # Clean up old database records
+ cursor = connection.cursor()
+ cursor.execute("DELETE FROM %s WHERE %s < NOW()" % \
+ (backend.quote_name('django_session'), backend.quote_name('expire_date')))
+ transaction.commit_unless_managed()
+
+cleanup.help_doc = 'Runs the daily cleanup job for this site'
+cleanup.args = ""
+
+

# Utilities for command-line script

DEFAULT_ACTION_MAPPING = {

@@ -1212,6 +1226,7 @@

'syncdb': syncdb,
'validate': validate,
'test':test,

+ 'cleanup':cleanup,

}

NO_SQL_TRANSACTION = (

@@ -1223,6 +1238,7 @@

'reset',
'sqlindexes',
'syncdb',

+ 'cleanup',

)

class DjangoOptionParser(OptionParser):

@@ -1296,7 +1312,7 @@

if action == 'shell':

action_mapping[action](options.plain is True)

  • elif action in ('validate', 'diffsettings', 'dbshell'):

+ elif action in ('validate', 'diffsettings', 'dbshell', 'cleanup'):

action_mapping[action]()

elif action == 'syncdb':

action_mapping[action](int(options.verbosity), options.interactive)

Change History (2)

comment:1 by anonymous, 18 years ago

Resolution: wontfix
Status: newclosed

Firstly, you don't explain what the problem is that you're trying to fix. Why is daily_cleanup outdated? Secondly, this sort of thing doesn't belong in manage.py. And finally, in the future (and I hope you will continue to offer up improvements in the future), please attach patches as attachments (create the ticket first, then edit it and attach the file). It is not easy to work with code fragments pasted in the body as you have done.

comment:2 by Malcolm Tredinnick, 18 years ago

Sorry. That resolution was made by me.

Note: See TracTickets for help on using tickets.
Back to Top