Author: jezdez
Date: 2012-02-09 10:56:49 -0800 (Thu, 09 Feb 2012)
New Revision: 17468

Modified:
   django/trunk/django/contrib/sitemaps/__init__.py
   django/trunk/docs/releases/1.4.txt
Log:
Fixed #10793 -- Stopped caching paginator instances in sitemap classes to 
prevent stale sitemaps. Thanks, gnosek, krzysiumed and adam_przybyla.

Modified: django/trunk/django/contrib/sitemaps/__init__.py
===================================================================
--- django/trunk/django/contrib/sitemaps/__init__.py    2012-02-09 18:56:41 UTC 
(rev 17467)
+++ django/trunk/django/contrib/sitemaps/__init__.py    2012-02-09 18:56:49 UTC 
(rev 17468)
@@ -60,9 +60,7 @@
         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):

Modified: django/trunk/docs/releases/1.4.txt
===================================================================
--- django/trunk/docs/releases/1.4.txt  2012-02-09 18:56:41 UTC (rev 17467)
+++ django/trunk/docs/releases/1.4.txt  2012-02-09 18:56:49 UTC (rev 17468)
@@ -1150,3 +1150,18 @@
 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>`.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to