Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #10793 -- Stopped caching paginator instances in sitemap classe…

…s to prevent stale sitemaps. Thanks, gnosek, krzysiumed and adam_przybyla.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17468 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 75a9c8a5ef6408cd51fd75fc8aefb2e812e353a1 1 parent 538257b
Jannis Leidel authored February 09, 2012
4  django/contrib/sitemaps/__init__.py
@@ -60,9 +60,7 @@ def location(self, obj):
60 60
         return obj.get_absolute_url()
61 61
 
62 62
     def _get_paginator(self):
63  
-        if not hasattr(self, "_paginator"):
64  
-            self._paginator = paginator.Paginator(self.items(), self.limit)
65  
-        return self._paginator
  63
+        return paginator.Paginator(self.items(), self.limit)
66 64
     paginator = property(_get_paginator)
67 65
 
68 66
     def get_urls(self, page=1, site=None, protocol=None):
15  docs/releases/1.4.txt
@@ -1150,3 +1150,18 @@ settings file to list all your applications explicitly.
1150 1150
 This attribute was confusingly named ``HttpRequest.raw_post_data``, but it
1151 1151
 actually provided the body of the HTTP request. It's been renamed to
1152 1152
 ``HttpRequest.body``, and ``HttpRequest.raw_post_data`` has been deprecated.
  1153
+
  1154
+``django.contrib.sitemaps`` bugfix with potential performance implications
  1155
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1156
+
  1157
+In previous versions the Paginator objects used in sitemap classes were
  1158
+cached and could result in stale sitemap indexes. Removing this cache causes
  1159
+new Paginator objects to be created and the
  1160
+:attr:`~django.contrib.sitemaps.Sitemap.items()` method of the
  1161
+:class:`~django.contrib.sitemaps.Sitemap` subclass to be called during every
  1162
+sitemap-related request.
  1163
+
  1164
+If the :attr:`django.contrib.sitemaps.Sitemap.items()` method returns a
  1165
+``QuerySet`` its length will be evaluated which may lead to extra database
  1166
+queries. To mitigate the performance impact consider using the :doc:`caching
  1167
+framework </topics/cache>`.

0 notes on commit 75a9c8a

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