diff options
author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-06-03 04:45:23 +0000 |
---|---|---|
committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-06-03 04:45:23 +0000 |
commit | bb97eea9ec88978ecd5dca0a17d9b3ba344f9152 (patch) | |
tree | 452049c9841e7adcfe3051488135f7873b81db3e /django | |
parent | 554f4e7aa8a3ffe65cac3b6698906c06e7db4fe6 (diff) | |
download | django-bb97eea9ec88978ecd5dca0a17d9b3ba344f9152.tar.gz |
unicode: Merged from trunk up to [5418].
git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5419 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r-- | django/bin/daily_cleanup.py | 10 | ||||
-rw-r--r-- | django/conf/project_template/settings.py | 5 | ||||
-rw-r--r-- | django/contrib/comments/feeds.py | 9 | ||||
-rw-r--r-- | django/core/serializers/json.py | 2 | ||||
-rw-r--r-- | django/core/serializers/pyyaml.py | 2 | ||||
-rw-r--r-- | django/db/backends/dummy/base.py | 5 | ||||
-rw-r--r-- | django/middleware/common.py | 2 |
7 files changed, 23 insertions, 12 deletions
diff --git a/django/bin/daily_cleanup.py b/django/bin/daily_cleanup.py index 3b83583d73..c87be1e4c3 100644 --- a/django/bin/daily_cleanup.py +++ b/django/bin/daily_cleanup.py @@ -7,13 +7,13 @@ Can be run as a cronjob to clean out old data from the database (only expired sessions at the moment). """ -from django.db import backend, connection, transaction +import datetime +from django.db import transaction +from django.contrib.sessions.models import Session def clean_up(): - # 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'))) + """Clean up expired sessions.""" + Session.objects.filter(expire_date__lt=datetime.datetime.now()).delete() transaction.commit_unless_managed() if __name__ == "__main__": diff --git a/django/conf/project_template/settings.py b/django/conf/project_template/settings.py index cadb5146b7..36039d7e98 100644 --- a/django/conf/project_template/settings.py +++ b/django/conf/project_template/settings.py @@ -38,8 +38,9 @@ USE_I18N = True # Example: "/home/media/media.lawrence.com/" MEDIA_ROOT = '' -# URL that handles the media served from MEDIA_ROOT. -# Example: "http://media.lawrence.com" +# URL that handles the media served from MEDIA_ROOT. Make sure to use a +# trailing slash if there is a path component (optional in other cases). +# Examples: "http://media.lawrence.com", "http://example.com/media/" MEDIA_URL = '' # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a diff --git a/django/contrib/comments/feeds.py b/django/contrib/comments/feeds.py index 2f395318b6..417e1d928a 100644 --- a/django/contrib/comments/feeds.py +++ b/django/contrib/comments/feeds.py @@ -23,16 +23,19 @@ class LatestFreeCommentsFeed(Feed): self._site = Site.objects.get_current() return u"Latest comments on %s" % self._site.name + def get_query_set(self): + return self.comments_class.objects.filter(site__pk=settings.SITE_ID, is_public=True) + def items(self): - return self.comments_class.objects.filter(site__pk=settings.SITE_ID, is_public=True)[:40] + return self.get_query_set()[:40] class LatestCommentsFeed(LatestFreeCommentsFeed): """Feed of latest free comments on the current site""" comments_class = Comment - def items(self): - qs = LatestFreeCommentsFeed.items(self) + def get_query_set(self): + qs = super(LatestCommentsFeed, self).get_query_set() qs = qs.filter(is_removed=False) if settings.COMMENTS_BANNED_USERS_GROUP: where = ['user_id NOT IN (SELECT user_id FROM auth_users_group WHERE group_id = %s)'] diff --git a/django/core/serializers/json.py b/django/core/serializers/json.py index 55804b8316..fa2dca7295 100644 --- a/django/core/serializers/json.py +++ b/django/core/serializers/json.py @@ -21,6 +21,8 @@ class Serializer(PythonSerializer): Convert a queryset to JSON. """ def end_serialization(self): + self.options.pop('stream', None) + self.options.pop('fields', None) simplejson.dump(self.objects, self.stream, cls=DjangoJSONEncoder, **self.options) def getvalue(self): diff --git a/django/core/serializers/pyyaml.py b/django/core/serializers/pyyaml.py index e239681912..92159dbbe3 100644 --- a/django/core/serializers/pyyaml.py +++ b/django/core/serializers/pyyaml.py @@ -18,6 +18,8 @@ class Serializer(PythonSerializer): Convert a queryset to YAML. """ def end_serialization(self): + self.options.pop('stream', None) + self.options.pop('fields', None) yaml.dump(self.objects, self.stream, **self.options) def getvalue(self): diff --git a/django/db/backends/dummy/base.py b/django/db/backends/dummy/base.py index 6a909016fc..d0ec897407 100644 --- a/django/db/backends/dummy/base.py +++ b/django/db/backends/dummy/base.py @@ -12,6 +12,9 @@ from django.core.exceptions import ImproperlyConfigured def complain(*args, **kwargs): raise ImproperlyConfigured, "You haven't set the DATABASE_ENGINE setting yet." +def ignore(*args, **kwargs): + pass + class DatabaseError(Exception): pass @@ -21,7 +24,7 @@ class IntegrityError(DatabaseError): class DatabaseWrapper: cursor = complain _commit = complain - _rollback = complain + _rollback = ignore def __init__(self, **kwargs): pass diff --git a/django/middleware/common.py b/django/middleware/common.py index 2c72c9a583..5f671dff7d 100644 --- a/django/middleware/common.py +++ b/django/middleware/common.py @@ -75,7 +75,7 @@ class CommonMiddleware(object): # Use ETags, if requested. if settings.USE_ETAGS: etag = md5.new(response.content).hexdigest() - if request.META.get('HTTP_IF_NONE_MATCH') == etag: + if response.status_code >= 200 and response.status_code < 300 and request.META.get('HTTP_IF_NONE_MATCH') == etag: response = http.HttpResponseNotModified() else: response['ETag'] = etag |