def reload_urlconf(urlconf=None, new_revision=None): if 'cms.urls' in sys.modules: reload(sys.modules['cms.urls']) if urlconf is None: urlconf = settings.ROOT_URLCONF if urlconf in sys.modules: reload(sys.modules[urlconf]) clear_app_resolvers() clear_url_caches() get_app_patterns() if new_revision is not None: set_local_revision(new_revision)
def reload_urls(settings, urlconf=None, cms_apps=True): if 'cms.urls' in sys.modules: reload_module(sys.modules['cms.urls']) if urlconf is None: urlconf = settings.ROOT_URLCONF if urlconf in sys.modules: reload_module(sys.modules[urlconf]) clear_url_caches() if cms_apps: from cms.appresolver import clear_app_resolvers, get_app_patterns clear_app_resolvers() get_app_patterns()
def reload_urlconf(urlconf=None, new_revision=None): from cms.appresolver import clear_app_resolvers, get_app_patterns if 'cms.urls' in sys.modules: reload(sys.modules['cms.urls']) if urlconf is None: urlconf = settings.ROOT_URLCONF if urlconf in sys.modules: reload(sys.modules[urlconf]) clear_app_resolvers() clear_url_caches() get_app_patterns() if new_revision is not None: set_local_revision(new_revision)
def reload_urlconf(urlconf=None): if 'cms.urls' in sys.modules: reload_module(sys.modules['cms.urls']) if urlconf is None: urlconf = settings.ROOT_URLCONF if urlconf in sys.modules: reload_module(sys.modules[urlconf]) clear_url_caches() try: from cms.appresolver import clear_app_resolvers, get_app_patterns clear_app_resolvers() get_app_patterns() except ImportError: pass
def test_apphook_breaking_under_home_with_new_path_caching(self): with SettingsOverride(CMS_PERMISSION=False): home = create_page("home", "nav_playground.html", "en", published=True) child = create_page("child", "nav_playground.html", "en", published=True, parent=home) # not-home is what breaks stuff, because it contains the slug of the home page not_home = create_page("not-home", "nav_playground.html", "en", published=True, parent=child) create_page("subchild", "nav_playground.html", "en", published=True, parent=not_home, apphook='SampleApp') with force_language("en"): self.reload_urls() urlpatterns = get_app_patterns() resolver = urlpatterns[0] url = resolver.reverse('sample-root') self.assertEqual(url, 'child/not-home/subchild/')
def test_apphook_breaking_under_home_with_new_path_caching(self): with SettingsOverride(CMS_MODERATOR=False, CMS_PERMISSION=False): home = create_page("home", "nav_playground.html", "en", published=True) child = create_page("child", "nav_playground.html", "en", published=True, parent=home) # not-home is what breaks stuff, because it contains the slug of the home page not_home = create_page("not-home", "nav_playground.html", "en", published=True, parent=child) create_page("subchild", "nav_playground.html", "en", published=True, parent=not_home, apphook='SampleApp') urlpatterns = get_app_patterns() resolver = urlpatterns[0] url = resolver.reverse('sample-root') self.assertEqual(url, 'child/not-home/subchild/')
def test_apphook_breaking_under_home_with_new_path_caching(self): home = create_page("home", "nav_playground.html", "en", published=True) child = create_page("child", "nav_playground.html", "en", published=True, parent=home) # not-home is what breaks stuff, because it contains the slug of the home page not_home = create_page("not-home", "nav_playground.html", "en", published=True, parent=child) create_page("subchild", "nav_playground.html", "en", published=True, parent=not_home, apphook='SampleApp') with force_language("en"): self.reload_urls() urlpatterns = get_app_patterns() resolver = urlpatterns[0] url = resolver.reverse('sample-root') self.assertEqual(url, 'child/not-home/subchild/')
# -*- coding: utf-8 -*- from django.conf import settings from django.conf.urls import url from cms.apphook_pool import apphook_pool from cms.appresolver import get_app_patterns from cms.views import details if settings.APPEND_SLASH: regex = r'^(?P<slug>[0-9A-Za-z-_.//]+)/$' else: regex = r'^(?P<slug>[0-9A-Za-z-_.//]+)$' if apphook_pool.get_apphooks(): # If there are some application urls, use special resolver, # so we will have standard reverse support. urlpatterns = get_app_patterns() else: urlpatterns = [] urlpatterns.extend([ url(regex, details, name='pages-details-by-slug'), url(r'^$', details, {'slug': ''}, name='pages-root'), ])
# -*- coding: utf-8 -*- from cms.apphook_pool import apphook_pool from cms.views import details from django.conf import settings from django.conf.urls import url, patterns if settings.APPEND_SLASH: reg = url(r'^(?P<slug>[0-9A-Za-z-_.//]+)/$', details, name='pages-details-by-slug') else: reg = url(r'^(?P<slug>[0-9A-Za-z-_.//]+)$', details, name='pages-details-by-slug') urlpatterns = [ # Public pages url(r'^$', details, {'slug':''}, name='pages-root'), reg, ] if apphook_pool.get_apphooks(): """If there are some application urls, add special resolver, so we will have standard reverse support. """ from cms.appresolver import get_app_patterns urlpatterns = get_app_patterns() + urlpatterns urlpatterns = patterns('', *urlpatterns)