Ticket #17802: pass-the-request-down-to-the-sitemap-callable.diff
File pass-the-request-down-to-the-sitemap-callable.diff, 1.9 KB (added by , 13 years ago) |
---|
-
django/contrib/sitemaps/views.py
13 13 sites = [] 14 14 for section, site in sitemaps.items(): 15 15 if callable(site): 16 site = site( )16 site = site(request=request) 17 17 protocol = req_protocol if site.protocol is None else site.protocol 18 18 sitemap_url = urlresolvers.reverse( 19 19 sitemap_url_name, kwargs={'section': section}) … … 42 42 for site in maps: 43 43 try: 44 44 if callable(site): 45 site = site( )45 site = site(request=request) 46 46 urls.extend(site.get_urls(page=page, site=req_site, 47 47 protocol=req_protocol)) 48 48 except EmptyPage: -
django/contrib/sitemaps/__init__.py
40 40 # http://sitemaps.org/protocol.php#index. 41 41 limit = 50000 42 42 43 def __init__(self, request=None): 44 self.request = request 45 43 46 # If protocol is None, the URLs in the sitemap will use the protocol 44 47 # with which the sitemap was requested. 45 48 protocol = None … … 104 107 priority = None 105 108 changefreq = None 106 109 107 def __init__(self, info_dict, priority=None, changefreq=None ):110 def __init__(self, info_dict, priority=None, changefreq=None, request=None): 108 111 self.queryset = info_dict['queryset'] 109 112 self.date_field = info_dict.get('date_field', None) 110 113 self.priority = priority 111 114 self.changefreq = changefreq 115 self.request = request 112 116 113 117 def items(self): 114 118 # Make sure to return a clone; we don't want premature evaluation.