Ticket #10909: sitemaps2.patch

File sitemaps2.patch, 1.9 KB (added by QingFeng, 16 years ago)

Google ping modify the domain settings

  • django/contrib/sitemaps/__init__.py

     
    11from django.core import urlresolvers, paginator
     2from django.conf import settings
    23import urllib
    34
    45PING_URL = "http://www.google.com/webmasters/tools/ping"
     
    2728    if sitemap_url is None:
    2829        raise SitemapNotFound("You didn't provide a sitemap_url, and the sitemap URL couldn't be auto-detected.")
    2930
    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)
     31    if 'DOMAIN' in settings.get_all_members():
     32        domain = settings.DOMAIN
     33    else:
     34        from django.contrib.sites.models import Site
     35        current_site = Site.objects.get_current()
     36        domain = current_site.domain
     37    url = "http://%s%s" % (domain, sitemap_url)
    3338    params = urllib.urlencode({'sitemap':url})
    3439    urllib.urlopen("%s?%s" % (ping_url, params))
    3540
     
    6065    paginator = property(_get_paginator)
    6166
    6267    def get_urls(self, page=1):
    63         from django.contrib.sites.models import Site
    64         current_site = Site.objects.get_current()
     68        if 'DOMAIN' in settings.get_all_members():
     69            domain = settings.DOMAIN
     70        else:
     71            from django.contrib.sites.models import Site
     72            current_site = Site.objects.get_current()
     73            domain = current_site.domain
    6574        urls = []
    6675        for item in self.paginator.page(page).object_list:
    67             loc = "http://%s%s" % (current_site.domain, self.__get('location', item))
     76            loc = "http://%s%s" % (domain, self.__get('location', item))
    6877            url_info = {
    6978                'location':   loc,
    7079                'lastmod':    self.__get('lastmod', item, None),
Back to Top