Browse files

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

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

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 538257b commit 75a9c8a5ef6408cd51fd75fc8aefb2e812e353a1 @jezdez jezdez committed Feb 9, 2012
Showing with 16 additions and 3 deletions.
  1. +1 −3 django/contrib/sitemaps/
  2. +15 −0 docs/releases/1.4.txt
@@ -60,9 +60,7 @@ def location(self, obj):
return obj.get_absolute_url()
def _get_paginator(self):
- if not hasattr(self, "_paginator"):
- self._paginator = paginator.Paginator(self.items(), self.limit)
- return self._paginator
+ return paginator.Paginator(self.items(), self.limit)
paginator = property(_get_paginator)
def get_urls(self, page=1, site=None, protocol=None):
@@ -1150,3 +1150,18 @@ settings file to list all your applications explicitly.
This attribute was confusingly named ``HttpRequest.raw_post_data``, but it
actually provided the body of the HTTP request. It's been renamed to
``HttpRequest.body``, and ``HttpRequest.raw_post_data`` has been deprecated.
+``django.contrib.sitemaps`` bugfix with potential performance implications
+In previous versions the Paginator objects used in sitemap classes were
+cached and could result in stale sitemap indexes. Removing this cache causes
+new Paginator objects to be created and the
+:attr:`~django.contrib.sitemaps.Sitemap.items()` method of the
+:class:`~django.contrib.sitemaps.Sitemap` subclass to be called during every
+sitemap-related request.
+If the :attr:`django.contrib.sitemaps.Sitemap.items()` method returns a
+``QuerySet`` its length will be evaluated which may lead to extra database
+queries. To mitigate the performance impact consider using the :doc:`caching
+framework </topics/cache>`.

0 comments on commit 75a9c8a

Please sign in to comment.