Ticket #14433: 14433.diff
File 14433.diff, 4.8 KB (added by , 14 years ago) |
---|
-
django/contrib/gis/sitemaps/georss.py
36 36 else: 37 37 self.locations.append(section) 38 38 39 def get_urls(self, page=1 ):39 def get_urls(self, page=1, site=None): 40 40 """ 41 41 This method is overrridden so the appropriate `geo_format` attribute 42 42 is placed on each URL element. 43 43 """ 44 urls = Sitemap.get_urls(self, page=page )44 urls = Sitemap.get_urls(self, page=page, site=site) 45 45 for url in urls: url['geo_format'] = 'georss' 46 46 return urls 47 47 -
django/contrib/gis/sitemaps/kml.py
40 40 raise TypeError('KML Sources must be a model or a 3-tuple.') 41 41 return kml_sources 42 42 43 def get_urls(self, page=1 ):43 def get_urls(self, page=1, site=None): 44 44 """ 45 45 This method is overrridden so the appropriate `geo_format` attribute 46 46 is placed on each URL element. 47 47 """ 48 urls = Sitemap.get_urls(self, page=page )48 urls = Sitemap.get_urls(self, page=page, site=site) 49 49 for url in urls: url['geo_format'] = self.geo_format 50 50 return urls 51 51 -
django/contrib/gis/sitemaps/views.py
46 46 maps = sitemaps.values() 47 47 48 48 page = request.GET.get("p", 1) 49 current_site = get_current_site(request) 49 50 for site in maps: 50 51 try: 51 52 if callable(site): 52 urls.extend(site().get_urls(page ))53 urls.extend(site().get_urls(page, current_site)) 53 54 else: 54 urls.extend(site.get_urls(page ))55 urls.extend(site.get_urls(page, current_site)) 55 56 except EmptyPage: 56 57 raise Http404("Page %s empty" % page) 57 58 except PageNotAnInteger: -
django/contrib/sitemaps/__init__.py
1 from django.contrib.sites.models import get_current_site1 from django.contrib.sites.models import Site, get_current_site 2 2 from django.core import urlresolvers, paginator 3 3 import urllib 4 4 … … 60 60 return self._paginator 61 61 paginator = property(_get_paginator) 62 62 63 def get_urls(self, page=1): 64 current_site = get_current_site(self.request) 63 def get_urls(self, page=1, site=None): 64 if site is None: 65 try: 66 site = Site.objects.get_current() 67 except Site.DoesNotExist: 68 raise ImproperlyConfigured("In order to use Sitemaps you must either use the sites framework or pass in a Site or RequestSite object in your view code.") 65 69 urls = [] 66 70 for item in self.paginator.page(page).object_list: 67 loc = "http://%s%s" % ( current_site.domain, self.__get('location', item))71 loc = "http://%s%s" % (site.domain, self.__get('location', item)) 68 72 priority = self.__get('priority', item, None) 69 73 url_info = { 70 74 'location': loc, … … 77 81 78 82 class FlatPageSitemap(Sitemap): 79 83 def items(self): 80 current_site = get_current_site(self.request) 81 if hasattr(current_site, "flatpage_set"): 82 return current_site.flatpage_set.filter(registration_required=False) 83 else: 84 return () 84 current_site = Site.objects.get_current() 85 return current_site.flatpage_set.filter(registration_required=False) 85 86 86 87 class GenericSitemap(Sitemap): 87 88 priority = None -
django/contrib/sitemaps/views.py
32 32 else: 33 33 maps = sitemaps.values() 34 34 page = request.GET.get("p", 1) 35 current_site = get_current_site(request) 35 36 for site in maps: 36 site.request = request37 37 try: 38 38 if callable(site): 39 urls.extend(site().get_urls(page ))39 urls.extend(site().get_urls(page, current_site)) 40 40 else: 41 urls.extend(site.get_urls(page ))41 urls.extend(site.get_urls(page, current_site)) 42 42 except EmptyPage: 43 43 raise Http404("Page %s empty" % page) 44 44 except PageNotAnInteger: