Author: adrian
Date: 2006-08-31 18:44:26 -0500 (Thu, 31 Aug 2006)
New Revision: 3699

Added:
   django/trunk/django/contrib/sitemaps/
   django/trunk/django/contrib/sitemaps/__init__.py
   django/trunk/django/contrib/sitemaps/templates/
   django/trunk/django/contrib/sitemaps/views.py
Removed:
   django/trunk/django/contrib/sitemap/
   django/trunk/django/contrib/sitemaps/__init__.py
   django/trunk/django/contrib/sitemaps/templates/
   django/trunk/django/contrib/sitemaps/views.py
Modified:
   django/trunk/docs/sitemaps.txt
Log:
Renamed django.contrib.sitemap to django.contrib.sitemaps, to be more 
consistent with our plural form for these sorts of things.

Copied: django/trunk/django/contrib/sitemaps (from rev 3694, 
django/trunk/django/contrib/sitemap)

Deleted: django/trunk/django/contrib/sitemaps/__init__.py
===================================================================
--- django/trunk/django/contrib/sitemap/__init__.py     2006-08-31 23:13:59 UTC 
(rev 3694)
+++ django/trunk/django/contrib/sitemaps/__init__.py    2006-08-31 23:44:26 UTC 
(rev 3699)
@@ -1,90 +0,0 @@
-from django.core import urlresolvers
-import urllib
-
-PING_URL = "http://www.google.com/webmasters/sitemaps/ping";
-
-class SitemapNotFound(Exception):
-    pass
-
-def ping_google(sitemap_url=None, ping_url=PING_URL):
-    """
-    Alerts Google that the sitemap for the current site has been updated.
-    If sitemap_url is provided, it should be an absolute path to the sitemap
-    for this site -- e.g., '/sitemap.xml'. If sitemap_url is not provided, this
-    function will attempt to deduce it by using urlresolvers.reverse().
-    """
-    if sitemap_url is None:
-        try:
-            # First, try to get the "index" sitemap URL.
-            sitemap_url = 
urlresolvers.reverse('django.contrib.sitemap.views.index')
-        except urlresolvers.NoReverseMatch:
-            try:
-                # Next, try for the "global" sitemap URL.
-                sitemap_url = 
urlresolvers.reverse('django.contrib.sitemap.views.sitemap')
-            except urlresolvers.NoReverseMatch:
-                pass
-
-    if sitemap_url is None:
-        raise SitemapNotFound("You didn't provide a sitemap_url, and the 
sitemap URL couldn't be auto-detected.")
-
-    from django.contrib.sites.models import Site
-    current_site = Site.objects.get_current()
-    url = "%s%s" % (current_site.domain, sitemap)
-    params = urllib.urlencode({'sitemap':url})
-    urllib.urlopen("%s?%s" % (ping_url, params))
-
-class Sitemap:
-    def __get(self, name, obj, default=None):
-        try:
-            attr = getattr(self, name)
-        except AttributeError:
-            return default
-        if callable(attr):
-            return attr(obj)
-        return attr
-
-    def items(self):
-        return []
-
-    def location(self, obj):
-        return obj.get_absolute_url()
-
-    def get_urls(self):
-        from django.contrib.sites.models import Site
-        current_site = Site.objects.get_current()
-        urls = []
-        for item in self.items():
-            loc = "http://%s%s"; % (current_site.domain, self.__get('location', 
item))
-            url_info = {
-                'location':   loc,
-                'lastmod':    self.__get('lastmod', item, None),
-                'changefreq': self.__get('changefreq', item, None),
-                'priority':   self.__get('priority', item, None)
-            }
-            urls.append(url_info)
-        return urls
-
-class FlatpageSitemap(Sitemap):
-    def items(self):
-        from django.contrib.sites.models import Site
-        current_site = Site.objects.get_current()
-        return current_site.flatpage_set.all()
-
-class GenericSitemap(Sitemap):
-    priority = None
-    changefreq = None
-
-    def __init__(self, info_dict, priority=None, changefreq=None):
-        self.queryset = info_dict['queryset']
-        self.date_field = info_dict.get('date_field', None)
-        self.priority = priority
-        self.changefreq = changefreq
-
-    def items(self):
-        # Make sure to return a clone; we don't want premature evaluation.
-        return self.queryset.filter()
-
-    def lastmod(self, item):
-        if self.date_field is not None:
-            return getattr(item, self.date_field)
-        return None

Copied: django/trunk/django/contrib/sitemaps/__init__.py (from rev 3698, 
django/trunk/django/contrib/sitemap/__init__.py)
===================================================================
--- django/trunk/django/contrib/sitemaps/__init__.py                            
(rev 0)
+++ django/trunk/django/contrib/sitemaps/__init__.py    2006-08-31 23:44:26 UTC 
(rev 3699)
@@ -0,0 +1,90 @@
+from django.core import urlresolvers
+import urllib
+
+PING_URL = "http://www.google.com/webmasters/sitemaps/ping";
+
+class SitemapNotFound(Exception):
+    pass
+
+def ping_google(sitemap_url=None, ping_url=PING_URL):
+    """
+    Alerts Google that the sitemap for the current site has been updated.
+    If sitemap_url is provided, it should be an absolute path to the sitemap
+    for this site -- e.g., '/sitemap.xml'. If sitemap_url is not provided, this
+    function will attempt to deduce it by using urlresolvers.reverse().
+    """
+    if sitemap_url is None:
+        try:
+            # First, try to get the "index" sitemap URL.
+            sitemap_url = 
urlresolvers.reverse('django.contrib.sitemap.views.index')
+        except urlresolvers.NoReverseMatch:
+            try:
+                # Next, try for the "global" sitemap URL.
+                sitemap_url = 
urlresolvers.reverse('django.contrib.sitemap.views.sitemap')
+            except urlresolvers.NoReverseMatch:
+                pass
+
+    if sitemap_url is None:
+        raise SitemapNotFound("You didn't provide a sitemap_url, and the 
sitemap URL couldn't be auto-detected.")
+
+    from django.contrib.sites.models import Site
+    current_site = Site.objects.get_current()
+    url = "%s%s" % (current_site.domain, sitemap)
+    params = urllib.urlencode({'sitemap':url})
+    urllib.urlopen("%s?%s" % (ping_url, params))
+
+class Sitemap:
+    def __get(self, name, obj, default=None):
+        try:
+            attr = getattr(self, name)
+        except AttributeError:
+            return default
+        if callable(attr):
+            return attr(obj)
+        return attr
+
+    def items(self):
+        return []
+
+    def location(self, obj):
+        return obj.get_absolute_url()
+
+    def get_urls(self):
+        from django.contrib.sites.models import Site
+        current_site = Site.objects.get_current()
+        urls = []
+        for item in self.items():
+            loc = "http://%s%s"; % (current_site.domain, self.__get('location', 
item))
+            url_info = {
+                'location':   loc,
+                'lastmod':    self.__get('lastmod', item, None),
+                'changefreq': self.__get('changefreq', item, None),
+                'priority':   self.__get('priority', item, None)
+            }
+            urls.append(url_info)
+        return urls
+
+class FlatPageSitemap(Sitemap):
+    def items(self):
+        from django.contrib.sites.models import Site
+        current_site = Site.objects.get_current()
+        return current_site.flatpage_set.all()
+
+class GenericSitemap(Sitemap):
+    priority = None
+    changefreq = None
+
+    def __init__(self, info_dict, priority=None, changefreq=None):
+        self.queryset = info_dict['queryset']
+        self.date_field = info_dict.get('date_field', None)
+        self.priority = priority
+        self.changefreq = changefreq
+
+    def items(self):
+        # Make sure to return a clone; we don't want premature evaluation.
+        return self.queryset.filter()
+
+    def lastmod(self, item):
+        if self.date_field is not None:
+            return getattr(item, self.date_field)
+        return None

Copied: django/trunk/django/contrib/sitemaps/templates (from rev 3698, 
django/trunk/django/contrib/sitemap/templates)

Deleted: django/trunk/django/contrib/sitemaps/views.py
===================================================================
--- django/trunk/django/contrib/sitemap/views.py        2006-08-31 23:13:59 UTC 
(rev 3694)
+++ django/trunk/django/contrib/sitemaps/views.py       2006-08-31 23:44:26 UTC 
(rev 3699)
@@ -1,30 +0,0 @@
-from django.http import HttpResponse, Http404
-from django.template import loader
-from django.contrib.sites.models import Site
-from django.core import urlresolvers
-
-def index(request, sitemaps):
-    current_site = Site.objects.get_current()
-    sites = []
-    protocol = request.is_secure() and 'https' or 'http'
-    for section in sitemaps.keys():
-        sitemap_url = 
urlresolvers.reverse('django.contrib.sitemap.views.sitemap', kwargs={'section': 
section})
-        sites.append('%s://%s%s' % (protocol, current_site.domain, 
sitemap_url))
-    xml = loader.render_to_string('sitemap_index.xml', {'sitemaps': sites})
-    return HttpResponse(xml, mimetype='application/xml')
-
-def sitemap(request, sitemaps, section=None):
-    maps, urls = [], []
-    if section is not None:
-        if not sitemaps.has_key(section):
-            raise Http404("No sitemap available for section: %r" % section)
-        maps.append(sitemaps[section])
-    else:
-        maps = sitemaps.values()
-    for site in maps:
-        if callable(site):
-            urls.extend(site().get_urls())
-        else:
-            urls.extend(site.get_urls())
-    xml = loader.render_to_string('sitemap.xml', {'urlset': urls})
-    return HttpResponse(xml, mimetype='application/xml')

Copied: django/trunk/django/contrib/sitemaps/views.py (from rev 3698, 
django/trunk/django/contrib/sitemap/views.py)
===================================================================
--- django/trunk/django/contrib/sitemaps/views.py                               
(rev 0)
+++ django/trunk/django/contrib/sitemaps/views.py       2006-08-31 23:44:26 UTC 
(rev 3699)
@@ -0,0 +1,30 @@
+from django.http import HttpResponse, Http404
+from django.template import loader
+from django.contrib.sites.models import Site
+from django.core import urlresolvers
+
+def index(request, sitemaps):
+    current_site = Site.objects.get_current()
+    sites = []
+    protocol = request.is_secure() and 'https' or 'http'
+    for section in sitemaps.keys():
+        sitemap_url = 
urlresolvers.reverse('django.contrib.sitemap.views.sitemap', kwargs={'section': 
section})
+        sites.append('%s://%s%s' % (protocol, current_site.domain, 
sitemap_url))
+    xml = loader.render_to_string('sitemap_index.xml', {'sitemaps': sites})
+    return HttpResponse(xml, mimetype='application/xml')
+
+def sitemap(request, sitemaps, section=None):
+    maps, urls = [], []
+    if section is not None:
+        if not sitemaps.has_key(section):
+            raise Http404("No sitemap available for section: %r" % section)
+        maps.append(sitemaps[section])
+    else:
+        maps = sitemaps.values()
+    for site in maps:
+        if callable(site):
+            urls.extend(site().get_urls())
+        else:
+            urls.extend(site.get_urls())
+    xml = loader.render_to_string('sitemap.xml', {'urlset': urls})
+    return HttpResponse(xml, mimetype='application/xml')

Modified: django/trunk/docs/sitemaps.txt
===================================================================
--- django/trunk/docs/sitemaps.txt      2006-08-31 23:31:25 UTC (rev 3698)
+++ django/trunk/docs/sitemaps.txt      2006-08-31 23:44:26 UTC (rev 3699)
@@ -31,7 +31,7 @@
 
 To install the sitemap app, follow these steps:
 
-    1. Add ``'django.contrib.sitemap'`` to your INSTALLED_APPS_ setting.
+    1. Add ``'django.contrib.sitemaps'`` to your INSTALLED_APPS_ setting.
     2. Make sure 
``'django.template.loaders.app_directories.load_template_source'``
        is in your TEMPLATE_LOADERS_ setting. It's in there by default, so
        you'll only need to change this if you've changed that setting.
@@ -51,7 +51,7 @@
 To activate sitemap generation on your Django site, add this line to your
 URLconf_:
 
-    (r'^sitemap.xml$', 'django.contrib.sitemap.views.sitemap', {'sitemaps': 
sitemaps})
+    (r'^sitemap.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': 
sitemaps})
 
 This tells Django to build a sitemap when a client accesses ``/sitemap.xml``.
 
@@ -82,7 +82,7 @@
 sitemap index that references individual sitemap files, one per section. (See
 `Creating a sitemap index`_ below.)
 
-``Sitemap`` classes must subclass ``django.contrib.sitemap.Sitemap``. They can
+``Sitemap`` classes must subclass ``django.contrib.sitemaps.Sitemap``. They can
 live anywhere in your codebase.
 
 A simple example
@@ -92,7 +92,7 @@
 sitemap to include all the links to your individual blog entries. Here's how
 your sitemap class might look::
 
-    from django.contrib.sitemap import Sitemap
+    from django.contrib.sitemaps import Sitemap
     from mysite.blog.models import Entry
 
     class BlogSitemap(Sitemap):
@@ -239,7 +239,7 @@
 Here's an example of a URLconf_ using both::
 
     from django.conf.urls.defaults import *
-    from django.contrib.sitemap import FlatPageSitemap, GenericSitemap
+    from django.contrib.sitemaps import FlatPageSitemap, GenericSitemap
     from mysite.blog.models import Entry
 
     info_dict = {
@@ -257,7 +257,7 @@
         # ...
 
         # the sitemap
-        (r'^sitemap.xml$', 'django.contrib.sitemap.views.sitemap', 
{'sitemaps': sitemaps})
+        (r'^sitemap.xml$', 'django.contrib.sitemaps.views.sitemap', 
{'sitemaps': sitemaps})
     )
 
 .. _URLconf: http://www.djangoproject.com/documentation/url_dispatch/
@@ -269,15 +269,15 @@
 references individual sitemap files, one per each section defined in your
 ``sitemaps`` dictionary. The only differences in usage are:
 
-    * You use two views in your URLconf: ``django.contrib.sitemap.views.index``
-      and ``django.contrib.sitemap.views.sitemap``.
-    * The ``django.contrib.sitemap.views.sitemap`` view should take a
+    * You use two views in your URLconf: 
``django.contrib.sitemaps.views.index``
+      and ``django.contrib.sitemaps.views.sitemap``.
+    * The ``django.contrib.sitemaps.views.sitemap`` view should take a
       ``section`` keyword argument.
 
 Here is what the relevant URLconf lines would look like for the example above::
 
-    (r'^sitemap.xml$', 'django.contrib.sitemap.views.index', {'sitemaps': 
sitemaps})
-    (r'^sitemap-(?P<section>.+).xml$', 'django.contrib.sitemap.views.sitemap', 
{'sitemaps': sitemaps})
+    (r'^sitemap.xml$', 'django.contrib.sitemaps.views.index', {'sitemaps': 
sitemaps})
+    (r'^sitemap-(?P<section>.+).xml$', 
'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps})
 
 This will automatically generate a ``sitemap.xml`` file that references
 both ``sitemap-flatpages.xml`` and ``sitemap-blog.xml``. The ``Sitemap``
@@ -288,7 +288,7 @@
 
 You may want to "ping" Google when your sitemap changes, to let it know to
 reindex your site. The framework provides a function to do just that:
-``django.contrib.sitemap.ping_google()``.
+``django.contrib.sitemaps.ping_google()``.
 
 ``ping_google()`` takes an optional argument, ``sitemap_url``, which should be
 the absolute URL of your site's sitemap (e.g., ``'/sitemap.xml'``). If this
@@ -296,12 +296,12 @@
 sitemap by performing a reverse looking in your URLconf.
 
 ``ping_google()`` raises the exception
-``django.contrib.sitemap.SitemapNotFound`` if it cannot determine your sitemap
+``django.contrib.sitemaps.SitemapNotFound`` if it cannot determine your sitemap
 URL.
 
 One useful way to call ``ping_google()`` is from a model's ``save()`` method::
 
-    from django.contrib.sitemap import ping_google
+    from django.contrib.sitemaps import ping_google
 
     class Entry(models.Model):
         # ...


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates
-~----------~----~----~----~------~----~------~--~---

Reply via email to