[geany/www.geany.org] aa4dae: Delay sitemap registration to actual app loading

Enrico Tröger git-noreply at xxxxx
Sun Jul 14 12:07:24 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 Jul 2019 12:07:24 UTC
Commit:      aa4dae2b8fa179042e72fce0b8e669eff7c645b4
             https://github.com/geany/www.geany.org/commit/aa4dae2b8fa179042e72fce0b8e669eff7c645b4

Log Message:
-----------
Delay sitemap registration to actual app loading

The previous attempt caused errors on "manage.py migrate" on an empty
database because Site objects were loaded in the Sitemap registry on
module import but the Sites framework database table was not created
yet.
So delay the sitemap registration to actual app loading to fix this
race condition.


Modified Paths:
--------------
    geany/settings.py
    latest_version/apps.py
    latest_version/urls.py
    news/apps.py
    news/urls.py
    nightlybuilds/apps.py
    pastebin/apps.py
    pastebin/urls.py
    static_docs/apps.py

Modified: geany/settings.py
14 lines changed, 7 insertions(+), 7 deletions(-)
===================================================================
@@ -318,17 +318,17 @@
     "mezzanine.twitter",
 
     # we
-    "geany",
-    "news",
-    "latest_version",
-    "static_docs",
-    "pastebin",         # pastebin.geany.org
-    "nightlybuilds",    # nightly.geany.org
+    "geany.apps.GeanyAppConfig",
+    "news.apps.NewsAppConfig",
+    "latest_version.apps.LatestVersionAppConfig",
+    "static_docs.apps.StaticDocsAppConfig",
+    "pastebin.apps.PastebinAppConfig",
+    "nightlybuilds.apps.NightlyBuildsAppConfig",
 
     # 3rd party
     "honeypot",     # for pastebin
     "mezzanine_pagedown",
-    "mezzanine_sync_pages",
+    "mezzanine_sync_pages.apps.MezzanineSyncPagesAppConfig",
 )
 
 # List of middleware classes to use. Order is important; in the request phase,


Modified: latest_version/apps.py
27 lines changed, 27 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,27 @@
+# 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.apps import AppConfig
+
+
+class LatestVersionAppConfig(AppConfig):
+    name = 'latest_version'
+    verbose_name = "LatestVersion"
+
+    # ----------------------------------------------------------------------
+    def ready(self):
+        # register our urlpatterns to the global sitemap generator
+        from geany.sitemaps import sitemap_registry, StaticSitemap
+        from latest_version.urls import urlpatterns
+        sitemap_registry.add(StaticSitemap, urlpatterns, exclude_views=['latest_version_legacy'])


Modified: latest_version/urls.py
5 lines changed, 0 insertions(+), 5 deletions(-)
===================================================================
@@ -15,8 +15,6 @@
 from django.conf.urls import url
 from django.views.generic import TemplateView
 
-from geany.sitemaps import sitemap_registry, StaticSitemap
-
 
 urlpatterns = (  # pylint: disable=invalid-name
     # special url for the UpdateChecker Geany plugin
@@ -30,6 +28,3 @@
         TemplateView.as_view(template_name='latest_version.txt', content_type='text/plain'),
         name='latest_version_legacy'),
 )
-
-# register our urlpatterns to the global sitemap generator
-sitemap_registry.add(StaticSitemap, urlpatterns, exclude_views=['latest_version_legacy'])


Modified: news/apps.py
28 lines changed, 28 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,28 @@
+# 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.apps import AppConfig
+
+
+class NewsAppConfig(AppConfig):
+    name = 'news'
+    verbose_name = "News"
+
+    # ----------------------------------------------------------------------
+    def ready(self):
+        # register our urlpatterns to the global sitemap generator
+        from geany.sitemaps import sitemap_registry
+        from news.sitemaps import NewsPostSitemap
+        from news.urls import urlpatterns
+        sitemap_registry.add(NewsPostSitemap, urlpatterns)


Modified: news/urls.py
5 lines changed, 0 insertions(+), 5 deletions(-)
===================================================================
@@ -14,9 +14,7 @@
 
 from django.conf.urls import url
 
-from geany.sitemaps import sitemap_registry
 from news.feeds import LatestNewsPostsFeed
-from news.sitemaps import NewsPostSitemap
 from news.views import NewsDetailView, NewsListView
 
 
@@ -25,6 +23,3 @@
     url(r'^feed/$', LatestNewsPostsFeed(), name='news_feed'),
     url(r'^(?P<newspost_slug>.+)/$', NewsDetailView.as_view(), name='news_detail'),
 )
-
-# register our urlpatterns to the global sitemap generator
-sitemap_registry.add(NewsPostSitemap, urlpatterns)


Modified: nightlybuilds/apps.py
20 lines changed, 20 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,20 @@
+# 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.apps import AppConfig
+
+
+class NightlyBuildsAppConfig(AppConfig):
+    name = 'nightlybuilds'
+    verbose_name = "Nightly Builds"


Modified: pastebin/apps.py
27 lines changed, 27 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,27 @@
+# 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.apps import AppConfig
+
+
+class PastebinAppConfig(AppConfig):
+    name = 'pastebin'
+    verbose_name = "Pastebin"
+
+    # ----------------------------------------------------------------------
+    def ready(self):
+        # Sitemap framework
+        from geany.sitemaps import sitemap_registry, StaticSitemap
+        from pastebin.urls import urlpatterns
+        sitemap_registry.add(StaticSitemap, urlpatterns, exclude_views=['snippet_api'])


Modified: pastebin/urls.py
5 lines changed, 0 insertions(+), 5 deletions(-)
===================================================================
@@ -16,7 +16,6 @@
 from django.views.decorators.cache import never_cache
 from django.views.generic.base import TemplateView
 
-from geany.sitemaps import sitemap_registry, StaticSitemap
 from pastebin.views import (
     LatestSnippetsView,
     SnippetAPIView,
@@ -54,7 +53,3 @@
         SnippetDetailRawView.as_view(),
         name='snippet_details_raw'),
 )
-
-
-# Sitemap framework
-sitemap_registry.add(StaticSitemap, urlpatterns, exclude_views=['snippet_api'])


Modified: static_docs/apps.py
20 lines changed, 20 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,20 @@
+# 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.apps import AppConfig
+
+
+class StaticDocsAppConfig(AppConfig):
+    name = 'static_docs'
+    verbose_name = "Static Docs"



--------------
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