[geany/www.geany.org] 318544: Remove django-hosts

Enrico Tröger git-noreply at xxxxx
Sat May 11 13:15:53 UTC 2019


Branch:      refs/heads/master
Author:      Enrico Tröger <enrico.troeger at uvena.de>
Committer:   Enrico Tröger <enrico.troeger at uvena.de>
Date:        Sun, 14 Apr 2019 23:22:40 UTC
Commit:      31854493a4a563270224b5d4aaf44fc69f1e5f49
             https://github.com/geany/www.geany.org/commit/31854493a4a563270224b5d4aaf44fc69f1e5f49

Log Message:
-----------
Remove django-hosts

The apps Pastebin and Nightly Builds were previously hosted on
seperate subdomains but are now mounted on a sub path on the
main site for simplicity.


Modified Paths:
--------------
    geany/hosts.py
    geany/settings.py
    geany/sitemaps.py
    requirements.txt

Modified: geany/hosts.py
52 lines changed, 0 insertions(+), 52 deletions(-)
===================================================================
@@ -1,52 +0,0 @@
-# -*- coding: utf-8 -*-
-# LICENCE: This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-from django_hosts import host, patterns
-from django_hosts.callbacks import cached_host_site
-
-
-# ----------------------------------------------------------------------
-def cached_host_site_extended(request, *args, **kwargs):
-    # call the original django-hosts callback to do the work
-    cached_host_site(request, *args, **kwargs)
-    # now if it found a site, append its site.id to the request for Mezzanine
-    if hasattr(request, 'site'):
-        # TODO talk to Stephen about this
-        request.site_id = request.site.id
-
-
-host_patterns = patterns(
-    '',
-    # nightlybuilds (nightly.geany.org and nightly.local.geany.org)
-    host(
-        r'^nightly(\.local|\.dev)?\.geany\.org(:[0-9]*)?$', 'nightlybuilds.urls',
-        name='nightly.geany.org',
-        callback=cached_host_site_extended),
-    host(
-        r'^geany\.nightlybuilds\.org(:[0-9]*)?$', 'nightlybuilds.urls',
-        name='geany.nightlybuilds.org',
-        callback=cached_host_site_extended),
-
-    # pastebin (pastebin.geany.org and pastebin.local.geany.org)
-    host(
-        r'^pastebin(\.local|\.dev)?\.geany\.org(:[0-9]*)?$', 'pastebin.urls',
-        name='pastebin.geany.org',
-        callback=cached_host_site_extended),
-
-    # default
-    host(
-        r'^www\.geany\.org(:[0-9]*)?$', 'geany.urls',
-        name='www.geany.org',
-        callback=cached_host_site_extended),
-)


Modified: geany/settings.py
7 lines changed, 0 insertions(+), 7 deletions(-)
===================================================================
@@ -322,7 +322,6 @@
 
     # 3rd party
     "honeypot",     # for pastebin
-    "django_hosts",
     "gunicorn",
     "mezzanine_pagedown",
 )
@@ -334,7 +333,6 @@
     "mezzanine.core.middleware.UpdateCacheMiddleware",
 
     "django.middleware.security.SecurityMiddleware",
-    "django_hosts.middleware.HostsRequestMiddleware",
     "django.contrib.sessions.middleware.SessionMiddleware",
     # Uncomment if using internationalisation or localisation
     # "django.middleware.locale.LocaleMiddleware",
@@ -352,7 +350,6 @@
     # Uncomment the following if using any of the SSL settings:
     # "mezzanine.core.middleware.SSLRedirectMiddleware",
     "mezzanine.pages.middleware.PageMiddleware",
-    "django_hosts.middleware.HostsResponseMiddleware",
     "mezzanine.core.middleware.FetchFromCacheMiddleware",
 )
 
@@ -437,10 +434,6 @@
 # django compressor
 COMPRESS_CSS_FILTERS = ['compressor.filters.cssmin.CSSMinFilter']
 
-# django-hosts
-ROOT_HOSTCONF = 'geany.hosts'
-DEFAULT_HOST = 'www.geany.org'
-
 # django-honeypot
 HONEYPOT_FIELD_NAME = 'website'
 


Modified: geany/sitemaps.py
9 lines changed, 3 insertions(+), 6 deletions(-)
===================================================================
@@ -15,7 +15,6 @@
 from django.contrib import sitemaps
 from django.contrib.sites.models import Site
 from django.urls import NoReverseMatch, reverse
-from django_hosts.resolvers import get_host
 from mezzanine.conf import settings
 from mezzanine.core.sitemaps import DisplayableSitemap
 
@@ -99,9 +98,8 @@ def __init__(self, domain, patterns):
         self._domain = domain
         self._patterns = patterns
         self._site = None
-        self._host = None
         self._url_mapping = {}
-        self._get_site_and_host()
+        self._get_site()
 
     # ----------------------------------------------------------------------
     def items(self):
@@ -121,14 +119,13 @@ def _initialize(self):
                     self._url_mapping[pattern.name] = url_resolved
 
     # ----------------------------------------------------------------------
-    def _get_site_and_host(self):
+    def _get_site(self):
         self._site = Site.objects.get(domain=self._domain)
-        self._host = get_host(self._domain)
 
     # ----------------------------------------------------------------------
     def _resolve_url(self, url):
         try:
-            return reverse(url, urlconf=self._host.urlconf)
+            return reverse(url)
         except NoReverseMatch:
             return None
 


Modified: requirements.txt
1 lines changed, 0 insertions(+), 1 deletions(-)
===================================================================
@@ -4,7 +4,6 @@ mysqlclient
 django-compressor
 django-extensions
 django-honeypot
-django-hosts
 django-memcache-status
 gunicorn
 mezzanine-pagedown



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list