magic-removal: More cleanup due to django.db move

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1638 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2005-12-14 06:30:14 +00:00
parent aecff3e245
commit 9f6f675e7b
5 changed files with 16 additions and 15 deletions

View File

@ -1,17 +1,17 @@
"Daily cleanup file"
from django.core.db import db
from django.db import backend, connection
DOCUMENTATION_DIRECTORY = '/home/html/documentation/'
def clean_up():
# Clean up old database records
cursor = db.cursor()
cursor = connection.cursor()
cursor.execute("DELETE FROM %s WHERE %s < NOW()" % \
(db.quote_name('core_sessions'), db.quote_name('expire_date')))
(backend.quote_name('core_sessions'), backend.quote_name('expire_date')))
cursor.execute("DELETE FROM %s WHERE %s < NOW() - INTERVAL '1 week'" % \
(db.quote_name('registration_challenges'), db.quote_name('request_date')))
db.commit()
(backend.quote_name('registration_challenges'), backend.quote_name('request_date')))
connection.commit()
if __name__ == "__main__":
clean_up()

View File

@ -41,8 +41,8 @@ class DjangoContext(Context):
self['LANGUAGE_CODE'] = settings.LANGUAGE_CODE
if DEBUG and request.META.get('REMOTE_ADDR') in INTERNAL_IPS:
self['debug'] = True
from django.core import db
self['sql_queries'] = db.db.queries
from django.db import connection
self['sql_queries'] = connection.queries
# PermWrapper and PermLookupDict proxy the permissions system into objects that
# the template system can understand.

View File

@ -47,12 +47,13 @@ class BaseHandler:
def get_response(self, path, request):
"Returns an HttpResponse object for the given HttpRequest"
from django.core import db, exceptions, urlresolvers
from django.core import exceptions, urlresolvers
from django.db import connection, DatabaseError
from django.core.mail import mail_admins
from django.conf.settings import DEBUG, INTERNAL_IPS, ROOT_URLCONF
# Reset query list per request.
db.db.queries = []
connection.queries = []
# Apply request middleware
for middleware_method in self._request_middleware:
@ -93,8 +94,8 @@ class BaseHandler:
else:
callback, param_dict = resolver.resolve404()
return callback(request, **param_dict)
except db.DatabaseError:
db.db.rollback()
except DatabaseError:
connection.rollback()
if DEBUG:
return self.get_technical_error_response(request)
else:

View File

@ -128,7 +128,7 @@ class ModPythonHandler(BaseHandler):
# now that the environ works we can see the correct settings, so imports
# that use settings now can work
from django.conf import settings
from django.core import db
from django.db import connection
# if we need to set up middleware, now that settings works we can do it now.
if self._request_middleware is None:
@ -138,7 +138,7 @@ class ModPythonHandler(BaseHandler):
request = ModPythonRequest(req)
response = self.get_response(req.uri, request)
finally:
db.db.close()
connection.close()
# Apply response middleware
for middleware_method in self._response_middleware:

View File

@ -143,7 +143,7 @@ class WSGIRequest(httpwrappers.HttpRequest):
class WSGIHandler(BaseHandler):
def __call__(self, environ, start_response):
from django.conf import settings
from django.core import db
from django.db import connection
# Set up middleware if needed. We couldn't do this earlier, because
# settings weren't available.
@ -154,7 +154,7 @@ class WSGIHandler(BaseHandler):
request = WSGIRequest(environ)
response = self.get_response(request.path, request)
finally:
db.db.close()
connection.close()
# Apply response middleware
for middleware_method in self._response_middleware: