diff --git a/django/contrib/sitemaps/__init__.py b/django/contrib/sitemaps/__init__.py
index 747cd1d..fc7f219 100644
a
|
b
|
from django.contrib.sites.models import Site
|
2 | 2 | from django.core import urlresolvers, paginator |
3 | 3 | from django.core.exceptions import ImproperlyConfigured |
4 | 4 | import urllib |
| 5 | from datetime import datetime, timedelta |
5 | 6 | |
6 | 7 | PING_URL = "http://www.google.com/webmasters/tools/ping" |
7 | 8 | |
… |
… |
class Sitemap(object):
|
39 | 40 | # This limit is defined by Google. See the index documentation at |
40 | 41 | # http://sitemaps.org/protocol.php#index. |
41 | 42 | limit = 50000 |
| 43 | counter_delta = timedelta(seconds = 60) |
| 44 | reload_delta = timedelta(seconds = 600) |
42 | 45 | |
43 | 46 | # If protocol is None, the URLs in the sitemap will use the protocol |
44 | 47 | # with which the sitemap was requested. |
… |
… |
class Sitemap(object):
|
60 | 63 | return obj.get_absolute_url() |
61 | 64 | |
62 | 65 | def _get_paginator(self): |
63 | | if not hasattr(self, "_paginator"): |
| 66 | __now = datetime.now() |
| 67 | # Do now have paginator or |
| 68 | if (not hasattr(self, "_paginator") or |
| 69 | # paginator very old or |
| 70 | (self.__paginator_validate_timestamp > __now) or |
| 71 | # paginator not so new and items count in DB changed |
| 72 | (self.__counter_validate_timestamp > __now and self.__counter != len(self.items()))): |
| 73 | |
| 74 | self.__counter_validate_timestamp = __now + self.counter_delta |
| 75 | self.__paginator_validate_timestamp = __now + self.reload_delta |
| 76 | self.__counter = len(self.items()) |
64 | 77 | self._paginator = paginator.Paginator(self.items(), self.limit) |
65 | 78 | return self._paginator |
66 | 79 | paginator = property(_get_paginator) |