Ticket #10909: 10909.diff
File 10909.diff, 1.9 KB (added by , 15 years ago) |
---|
-
django/contrib/sitemaps/__init__.py
27 27 if sitemap_url is None: 28 28 raise SitemapNotFound("You didn't provide a sitemap_url, and the sitemap URL couldn't be auto-detected.") 29 29 30 from django.contrib.sites.models import Site 31 current_site = Site.objects.get_current() 32 url = "http://%s%s" % (current_site.domain, sitemap_url) 33 params = urllib.urlencode({'sitemap':url}) 30 if '://' not in sitemap_url: 31 from django.contrib.sites.models import Site 32 current_site = Site.objects.get_current() 33 sitemap_url = "http://%s%s" % (current_site.domain, sitemap_url) 34 params = urllib.urlencode({'sitemap': sitemap_url}) 34 35 urllib.urlopen("%s?%s" % (ping_url, params)) 35 36 36 37 class Sitemap(object): … … 60 61 paginator = property(_get_paginator) 61 62 62 63 def get_urls(self, page=1): 63 from django.contrib.sites.models import Site64 current_site = Site.objects.get_current()65 64 urls = [] 66 65 for item in self.paginator.page(page).object_list: 67 loc = "http://%s%s" % (current_site.domain, self.__get('location', item)) 66 loc = "http://%s%s" % (self.get_domain(), 67 self.__get('location', item)) 68 68 url_info = { 69 69 'location': loc, 70 70 'lastmod': self.__get('lastmod', item, None), … … 74 74 urls.append(url_info) 75 75 return urls 76 76 77 def get_domain(self): 78 # This method can be overridden to avoid the requirement of the sites 79 # contrib application. 80 from django.contrib.sites.models import Site 81 return Site.objects.get_current().domain 82 77 83 class FlatPageSitemap(Sitemap): 78 84 def items(self): 79 85 from django.contrib.sites.models import Site