Esempio n. 1
0
    def tearDown(self):
        clear_app_resolvers()
        clear_url_caches()

        if APP_MODULE in sys.modules:
            del sys.modules[APP_MODULE]
        self.apphook_clear()
Esempio n. 2
0
    def reload_urls(self, apphook_objects=None):
        """
        Clean up url related things (caches, app resolvers, modules).
        Taken from cms.
        :return: None
        """
        clear_app_resolvers()
        clear_url_caches()

        if apphook_objects is None:
            apphook_objects = self.get_apphook_objects()

        apphooked_urls = []
        for apphook_object in apphook_objects:
            app_module = apphook_object.__module__
            package = app_module.split('.')[0]
            apphooked_urls.append('{0}.urls'.format(package))

        # build url modules
        url_modules = ['cms.urls']
        url_modules += apphooked_urls
        url_modules.append(settings.ROOT_URLCONF)

        for module in url_modules:
            if module in sys.modules:
                del sys.modules[module]
Esempio n. 3
0
    def test_get_i18n_apphook_with_explicit_current_app(self):
        self.apphook_clear()
        titles = self.create_base_structure(NS_APP_NAME, ['en', 'de'], 'instance_1')
        public_de_title = titles[1]
        de_title = Title.objects.get(page=public_de_title.page.publisher_draft, language="de")
        de_title.slug = "de"
        de_title.save()
        de_title.page.publish('de')

        self.reload_urls()
        self.apphook_clear()

        page2 = create_page("page2", "nav_playground.html",
                            "en", created_by=self.superuser, published=True, parent=de_title.page.parent,
                            apphook=NS_APP_NAME,
                            apphook_namespace="instance_2")
        create_title("de", "de_title", page2, slug="slug")
        page2.publish('de')
        clear_app_resolvers()
        clear_url_caches()

        if APP_MODULE in sys.modules:
            del sys.modules[APP_MODULE]

        self.reload_urls()
        with force_language("de"):
            reverse('namespaced_app_ns:current-app', current_app="instance_1")
            reverse('namespaced_app_ns:current-app', current_app="instance_2")
            reverse('namespaced_app_ns:current-app')
        with force_language("en"):
            reverse('namespaced_app_ns:current-app', current_app="instance_1")
            reverse('namespaced_app_ns:current-app', current_app="instance_2")
            reverse('namespaced_app_ns:current-app')
        self.apphook_clear()
Esempio n. 4
0
    def tearDown(self):
        clear_app_resolvers()
        clear_url_caches()

        if APP_MODULE in sys.modules:
            del sys.modules[APP_MODULE]
        self.apphook_clear()
Esempio n. 5
0
    def setUp(self):
        clear_app_resolvers()
        clear_url_caches()

        if APP_MODULE in sys.modules:
            del sys.modules[APP_MODULE]
        self.reload_urls()
Esempio n. 6
0
    def setUp(self):
        clear_app_resolvers()
        clear_url_caches()

        if APP_MODULE in sys.modules:
            del sys.modules[APP_MODULE]
        self.reload_urls()
Esempio n. 7
0
    def test_get_i18n_apphook_with_explicit_current_app(self):
        with SettingsOverride(ROOT_URLCONF='cms.test_utils.project.second_urls_for_apphook_tests'):
            titles = self.create_base_structure(NS_APP_NAME, ['en', 'de'], 'instance_1')
            public_de_title = titles[1]
            de_title = Title.objects.get(page=public_de_title.page.publisher_draft, language="de")
            de_title.slug = "de"
            de_title.save()
            de_title.page.publish('de')

            page2 = create_page("page2", "nav_playground.html",
                                "en", created_by=self.superuser, published=True, parent=de_title.page.parent,
                                apphook=NS_APP_NAME,
                                apphook_namespace="instance_2")
            create_title("de", "de_title", page2, slug="slug")
            page2.publish('de')
            clear_app_resolvers()
            clear_url_caches()

            if APP_MODULE in sys.modules:
                del sys.modules[APP_MODULE]

            self.reload_urls()
            with force_language("de"):
                reverse('namespaced_app_ns:current-app', current_app="instance_1")
                reverse('namespaced_app_ns:current-app', current_app="instance_2")
                reverse('namespaced_app_ns:current-app')
            with force_language("en"):
                reverse('namespaced_app_ns:current-app', current_app="instance_1")
                reverse('namespaced_app_ns:current-app', current_app="instance_2")
                reverse('namespaced_app_ns:current-app')
Esempio n. 8
0
    def reload_urls(self):
        from django.conf import settings

        url_modules = ["cms.urls", "cms.test_utils.project.second_cms_urls_for_apphook_tests", settings.ROOT_URLCONF]

        clear_app_resolvers()
        clear_url_caches()

        for module in url_modules:
            if module in sys.modules:
                del sys.modules[module]
Esempio n. 9
0
def refresh_cms_apps():
    from cms.appresolver import clear_app_resolvers
    clear_app_resolvers()

    from django.urls import clear_url_caches
    clear_url_caches()

    from django.conf import settings
    url_modules = ['cms.urls', settings.ROOT_URLCONF]
    for module in url_modules:
        if module in sys.modules:
            del sys.modules[module]
Esempio n. 10
0
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()
Esempio n. 11
0
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()
Esempio n. 12
0
    def reload_urls(self):
        clear_app_resolvers()
        clear_url_caches()
        url_modules = [
            'cms.urls',
            'aldryn_jobs.urls',
            settings.ROOT_URLCONF
        ]

        for module in url_modules:
            if module in sys.modules:
                del sys.modules[module]
Esempio n. 13
0
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)
Esempio n. 14
0
    def reload_urls(self):
        """
        Clean up url related things (caches, app resolvers, modules).
        Taken from cms.
        :return: None
        """
        clear_app_resolvers()
        clear_url_caches()
        url_modules = ['cms.urls', 'aldryn_events.urls', settings.ROOT_URLCONF]

        for module in url_modules:
            if module in sys.modules:
                del sys.modules[module]
    def reload_urls(self):
        url_modules = [
            'cms.urls',
            'test_addon.urls',
            settings.ROOT_URLCONF,
        ]

        clear_app_resolvers()
        clear_url_caches()

        for module in url_modules:
            if module in sys.modules:
                del sys.modules[module]
    def reload_urls(self):
        url_modules = [
            'cms.urls',
            'test_addon.urls',
            settings.ROOT_URLCONF,
        ]

        clear_app_resolvers()
        clear_url_caches()

        for module in url_modules:
            if module in sys.modules:
                del sys.modules[module]
Esempio n. 17
0
 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
Esempio n. 18
0
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)
Esempio n. 19
0
    def reload_urls(self):
        from django.conf import settings

        url_modules = [
            'cms.urls',
            self.APP_MODULE,
            settings.ROOT_URLCONF,
        ]

        clear_app_resolvers()
        clear_url_caches()

        for module in url_modules:
            if module in sys.modules:
                del sys.modules[module]
Esempio n. 20
0
    def reload_urls(self):
        from django.conf import settings

        url_modules = [
            'cms.urls',
            self.APP_MODULE,
            settings.ROOT_URLCONF,
        ]

        clear_app_resolvers()
        clear_url_caches()

        for module in url_modules:
            if module in sys.modules:
                del sys.modules[module]
Esempio n. 21
0
    def reload_urls(self):
        from django.conf import settings

        url_modules = [
            'cms.urls',
            'cms.test_utils.project.second_cms_urls_for_apphook_tests',
            settings.ROOT_URLCONF,
        ]

        clear_app_resolvers()
        clear_url_caches()

        for module in url_modules:
            if module in sys.modules:
                del sys.modules[module]
Esempio n. 22
0
def debug_server_restart(**kwargs):
    from cms.appresolver import clear_app_resolvers
    if 'runserver' in sys.argv or 'server' in sys.argv:
        clear_app_resolvers()
        clear_url_caches()
        import cms.urls
        try:
            reload(cms.urls)
        except NameError: #python3
            from imp import reload
            reload(cms.urls)
    if not 'test' in sys.argv:
        msg = 'Application url changed and urls_need_reloading signal fired. Please reload the urls.py or restart the server\n'
        styles = color_style()
        msg = styles.NOTICE(msg)
        sys.stderr.write(msg)
Esempio n. 23
0
def debug_server_restart(**kwargs):
    from cms.appresolver import clear_app_resolvers
    if 'runserver' in sys.argv or 'server' in sys.argv:
        clear_app_resolvers()
        clear_url_caches()
        import cms.urls
        try:
            reload(cms.urls)
        except NameError:  #python3
            from imp import reload
            reload(cms.urls)
    if not 'test' in sys.argv:
        msg = 'Application url changed and urls_need_reloading signal fired. Please reload the urls.py or restart the server\n'
        styles = color_style()
        msg = styles.NOTICE(msg)
        sys.stderr.write(msg)
Esempio n. 24
0
    def reload_urls(self):
        """
        Clean up url related things (caches, app resolvers, modules).
        Taken from cms.
        :return: None
        """
        clear_app_resolvers()
        clear_url_caches()
        url_modules = [
            'cms.urls',
            'aldryn_events.urls',
            settings.ROOT_URLCONF
        ]

        for module in url_modules:
            if module in sys.modules:
                del sys.modules[module]
Esempio n. 25
0
    def setUp(self):
        self.APP_MODULE = 'aldryn_forms.cms_apps.FormsApp'
        clear_app_resolvers()
        clear_url_caches()

        if self.APP_MODULE in sys.modules:
            del sys.modules[self.APP_MODULE]

        self.page = create_page(
            'tpage',
            'test_page.html',
            'en',
            published=True,
            apphook='FormsApp',
        )
        try:
            self.placeholder = self.page.placeholders.get(slot='content')
        except AttributeError:
            self.placeholder = self.page.get_placeholders('en').get(
                slot='content')

        self.redirect_url = 'http://www.google.com'

        plugin_data = {
            'redirect_type': 'redirect_to_url',
            'url': self.redirect_url,
        }
        self.form_plugin = add_plugin(self.placeholder, 'FormPlugin', 'en',
                                      **plugin_data)  # noqa: E501

        add_plugin(
            self.placeholder,
            'SubmitButton',
            'en',
            target=self.form_plugin,
            label='Submit',
        )
        self.form_plugin.action_backend = 'default'
        self.form_plugin.save()
        self.page.publish('en')

        self.reload_urls()
        self.apphook_clear()
Esempio n. 26
0
    def reload_urls(self):
        from django.conf import settings

        url_modules = [
            'cms.urls',
            # TODO: Add here intermediary modules which may
            #       include() the 'cms.urls' if it isn't included
            #       directly in the root urlconf.
            # '...',
            'cms.test_utils.project.second_cms_urls_for_apphook_tests',
            settings.ROOT_URLCONF,
        ]

        clear_app_resolvers()
        clear_url_caches()

        for module in url_modules:
            if module in sys.modules:
                del sys.modules[module]
Esempio n. 27
0
    def reload_urls(self, apphook_object=None):
        """
        Clean up url related things (caches, app resolvers, modules).
        Taken from cms.
        :return: None
        """
        if apphook_object is None:
            apphook_object = self.get_apphook_object()
        app_module = apphook_object.__module__
        package = app_module.split('.')[0]
        clear_app_resolvers()
        clear_url_caches()
        url_modules = [
            'cms.urls', '{0}.urls'.format(package), settings.ROOT_URLCONF
        ]

        for module in url_modules:
            if module in sys.modules:
                del sys.modules[module]
Esempio n. 28
0
    def reload_urls(self):
        from django.conf import settings

        url_modules = [
            'cms.urls',
            # TODO: Add here intermediary modules which may
            #       include() the 'cms.urls' if it isn't included
            #       directly in the root urlconf.
            # '...',
            'cms.test_utils.project.second_cms_urls_for_apphook_tests',
            settings.ROOT_URLCONF,
        ]

        clear_app_resolvers()
        clear_url_caches()

        for module in url_modules:
            if module in sys.modules:
                del sys.modules[module]
Esempio n. 29
0
    def setUp(self):
        self.APP_MODULE = 'aldryn_forms.cms_apps.FormsApp'
        clear_app_resolvers()
        clear_url_caches()

        if self.APP_MODULE in sys.modules:
            del sys.modules[self.APP_MODULE]

        self.page = create_page(
            'tpage',
            'test_page.html',
            'en',
            published=True,
            apphook='FormsApp',
        )
        try:
            self.placeholder = self.page.placeholders.get(slot='content')
        except AttributeError:
            self.placeholder = self.page.get_placeholders('en').get(slot='content')

        self.redirect_url = 'http://www.google.com'

        plugin_data = {
            'redirect_type': 'redirect_to_url',
            'url': self.redirect_url,
        }
        self.form_plugin = add_plugin(self.placeholder, 'FormPlugin', 'en', **plugin_data)  # noqa: E501

        add_plugin(
            self.placeholder,
            'SubmitButton',
            'en',
            target=self.form_plugin,
            label='Submit',
        )
        self.form_plugin.action_backend = 'default'
        self.form_plugin.save()
        if CMS_3_6:
            self.page.publish('en')

        self.reload_urls()
        self.apphook_clear()
Esempio n. 30
0
    def reload_urls(self, apphook_object=None):
        """
        Clean up url related things (caches, app resolvers, modules).
        Taken from cms.
        :return: None
        """
        if apphook_object is None:
            apphook_object = self.get_apphook_object()
        app_module = apphook_object.__module__
        package = app_module.split('.')[0]
        clear_app_resolvers()
        clear_url_caches()
        url_modules = [
            'cms.urls',
            '{0}.urls'.format(package),
            settings.ROOT_URLCONF
        ]

        for module in url_modules:
            if module in sys.modules:
                del sys.modules[module]
Esempio n. 31
0
    def test_get_i18n_apphook_with_explicit_current_app(self):
        with SettingsOverride(ROOT_URLCONF="cms.test_utils.project.second_urls_for_apphook_tests"):
            titles = self.create_base_structure(NS_APP_NAME, ["en", "de"], "instance_1")
            public_de_title = titles[1]
            de_title = Title.objects.get(page=public_de_title.page.publisher_draft, language="de")
            de_title.slug = "de"
            de_title.save()
            de_title.page.publish("de")

            page2 = create_page(
                "page2",
                "nav_playground.html",
                "en",
                created_by=self.superuser,
                published=True,
                parent=de_title.page.parent,
                apphook=NS_APP_NAME,
                apphook_namespace="instance_2",
            )
            create_title("de", "de_title", page2, slug="slug")
            page2.publish("de")
            clear_app_resolvers()
            clear_url_caches()

            if APP_MODULE in sys.modules:
                del sys.modules[APP_MODULE]

            self.reload_urls()
            with force_language("de"):
                reverse("namespaced_app_ns:current-app", current_app="instance_1")
                reverse("namespaced_app_ns:current-app", current_app="instance_2")
                reverse("namespaced_app_ns:current-app")
            with force_language("en"):
                reverse("namespaced_app_ns:current-app", current_app="instance_1")
                reverse("namespaced_app_ns:current-app", current_app="instance_2")
                reverse("namespaced_app_ns:current-app")
Esempio n. 32
0
 def setUp(self):
     clear_app_resolvers()
     clear_url_caches()
Esempio n. 33
0
 def get_overridden_urls(self):
     from cms.appresolver import clear_app_resolvers
     from django.core.urlresolvers import clear_url_caches
     clear_app_resolvers()
     clear_url_caches()
     return self.get_urls()
Esempio n. 34
0
 def setUp(self):
     clear_app_resolvers()
     clear_url_caches()