Ticket #10608: django_requestsite.patch
File django_requestsite.patch, 6.8 KB (added by , 16 years ago) |
---|
-
django/contrib/auth/forms.py
a b 1 1 from django.contrib.auth.models import User 2 2 from django.contrib.auth import authenticate 3 3 from django.contrib.auth.tokens import default_token_generator 4 from django.contrib.sites.models import Site 4 from django.contrib.sites.models import Site, RequestSite 5 5 from django.template import Context, loader 6 6 from django import forms 7 7 from django.utils.translation import ugettext_lazy as _ … … class PasswordResetForm(forms.Form): 116 116 from django.core.mail import send_mail 117 117 for user in self.users_cache: 118 118 if not domain_override: 119 current_site = Site.objects.get_current() 119 if Site._meta.installed: 120 current_site = Site.objects.get_current() 121 else: 122 current_site = RequestSite(request) 120 123 site_name = current_site.name 121 124 domain = current_site.domain 122 125 else: -
django/contrib/comments/feeds.py
a b 1 1 from django.conf import settings 2 2 from django.contrib.syndication.feeds import Feed 3 from django.contrib.sites.models import Site 3 from django.contrib.sites.models import Site, RequestSite 4 4 from django.contrib import comments 5 5 6 6 class LatestCommentFeed(Feed): … … class LatestCommentFeed(Feed): 8 8 9 9 def title(self): 10 10 if not hasattr(self, '_site'): 11 self._site = Site.objects.get_current() 11 if Site._meta.installed: 12 self._site = Site.objects.get_current() 13 else: 14 self._site = RequestSite(request) 12 15 return u"%s comments" % self._site.name 13 16 14 17 def link(self): 15 18 if not hasattr(self, '_site'): 16 self._site = Site.objects.get_current() 19 if Site._meta.installed: 20 self._site = Site.objects.get_current() 21 else: 22 self._site = RequestSite(request) 17 23 return "http://%s/" % (self._site.domain) 18 24 19 25 def description(self): 20 26 if not hasattr(self, '_site'): 21 self._site = Site.objects.get_current() 27 if Site._meta.installed: 28 self._site = Site.objects.get_current() 29 else: 30 self._site = RequestSite(request) 22 31 return u"Latest comments on %s" % self._site.name 23 32 24 33 def items(self): -
django/contrib/contenttypes/views.py
a b 1 1 from django import http 2 2 from django.contrib.contenttypes.models import ContentType 3 from django.contrib.sites.models import Site 3 from django.contrib.sites.models import Site, RequestSite 4 4 from django.core.exceptions import ObjectDoesNotExist 5 5 6 6 def shortcut(request, content_type_id, object_id): … … def shortcut(request, content_type_id, object_id): 54 54 # Fall back to the current site (if possible). 55 55 if object_domain is None: 56 56 try: 57 object_domain = Site.objects.get_current().domain 57 if Site._meta.installed: 58 object_domain = Site.objects.get_current().domain 59 else: 60 object_domain = RequestSite(request).domain 58 61 except Site.DoesNotExist: 59 62 pass 60 63 -
django/contrib/gis/sitemaps/views.py
a b 1 1 from django.http import HttpResponse, Http404 2 2 from django.template import loader 3 3 from django.contrib.gis.db.backend import SpatialBackend 4 from django.contrib.sites.models import Site 4 from django.contrib.sites.models import Site, RequestSite 5 5 from django.core import urlresolvers 6 6 from django.core.paginator import EmptyPage, PageNotAnInteger 7 7 from django.db.models import get_model … … def index(request, sitemaps): 15 15 This view generates a sitemap index that uses the proper view 16 16 for resolving geographic section sitemap URLs. 17 17 """ 18 current_site = Site.objects.get_current() 18 if Site._meta.installed: 19 current_site = Site.objects.get_current() 20 else: 21 current_site = RequestSite(request) 19 22 sites = [] 20 23 protocol = request.is_secure() and 'https' or 'http' 21 24 for section, site in sitemaps.items(): -
django/contrib/sitemaps/__init__.py
a b def ping_google(sitemap_url=None, ping_url=PING_URL): 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() 30 from django.contrib.sites.models import Site, RequestSite 31 if Site._meta.installed: 32 current_site = Site.objects.get_current() 33 else: 34 current_site = RequestSite(request) 32 35 url = "http://%s%s" % (current_site.domain, sitemap_url) 33 36 params = urllib.urlencode({'sitemap':url}) 34 37 urllib.urlopen("%s?%s" % (ping_url, params)) … … class Sitemap(object): 60 63 paginator = property(_get_paginator) 61 64 62 65 def get_urls(self, page=1): 63 from django.contrib.sites.models import Site 64 current_site = Site.objects.get_current() 66 from django.contrib.sites.models import Site, RequestSite 67 if Site._meta.installed: 68 current_site = Site.objects.get_current() 69 else: 70 current_site = RequestSite(request) 65 71 urls = [] 66 72 for item in self.paginator.page(page).object_list: 67 73 loc = "http://%s%s" % (current_site.domain, self.__get('location', item)) … … class Sitemap(object): 76 82 77 83 class FlatPageSitemap(Sitemap): 78 84 def items(self): 79 from django.contrib.sites.models import Site 80 current_site = Site.objects.get_current() 85 from django.contrib.sites.models import Site, RequestSite 86 if Site._meta.installed: 87 current_site = Site.objects.get_current() 88 else: 89 current_site = RequestSite(request) 81 90 return current_site.flatpage_set.all() 82 91 83 92 class GenericSitemap(Sitemap): -
django/contrib/sitemaps/views.py
a b 1 1 from django.http import HttpResponse, Http404 2 2 from django.template import loader 3 from django.contrib.sites.models import Site 3 from django.contrib.sites.models import Site, RequestSite 4 4 from django.core import urlresolvers 5 5 from django.utils.encoding import smart_str 6 6 from django.core.paginator import EmptyPage, PageNotAnInteger 7 7 8 8 def index(request, sitemaps): 9 current_site = Site.objects.get_current() 9 if Site._meta.installed: 10 current_site = Site.objects.get_current() 11 else: 12 current_site = RequestSite(request) 10 13 sites = [] 11 14 protocol = request.is_secure() and 'https' or 'http' 12 15 for section, site in sitemaps.items():