Ticket #25989: views.py.diff
File views.py.diff, 1.6 KB (added by , 9 years ago) |
---|
-
views.py
old new 58 58 maps = sitemaps.values() 59 59 page = request.GET.get("p", 1) 60 60 61 lastmod = None 62 61 63 urls = [] 62 64 for site in maps: 63 65 try: … … 65 67 site = site() 66 68 urls.extend(site.get_urls(page=page, site=req_site, 67 69 protocol=req_protocol)) 70 71 if hasattr(site, 'latest_lastmod'): 72 site_lastmod = site.latest_lastmod 73 74 if type(site_lastmod) is datetime.date: 75 site_lastmod = datetime.datetime(site_lastmod.year, 76 site_lastmod.month, 77 site_lastmod.day) 78 79 if lastmod is None or lastmod < site_lastmod: 80 lastmod = site_lastmod 81 68 82 except EmptyPage: 69 83 raise Http404("Page %s empty" % page) 70 84 except PageNotAnInteger: 71 85 raise Http404("No page '%s'" % page) 72 86 response = TemplateResponse(request, template_name, {'urlset': urls}, 73 87 content_type=content_type) 74 if hasattr(site, 'latest_lastmod'):75 # if la test_lastmod is defined forsite, set header so as88 if lastmod is not None: 89 # if lastmod is defined for at least one site, set header so as 76 90 # ConditionalGetMiddleware is able to send 304 NOT MODIFIED 77 lastmod = site.latest_lastmod78 91 response['Last-Modified'] = http_date( 79 92 timegm( 80 93 lastmod.utctimetuple() if isinstance(lastmod, datetime.datetime)