• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python menu_pool.clear函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中menus.menu_pool.menu_pool.clear函数的典型用法代码示例。如果您正苦于以下问题:Python clear函数的具体用法?Python clear怎么用?Python clear使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了clear函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: ready

    def ready(self):

        # ensure that current LeprikonSite exists
        from .models.leprikonsite import LeprikonSite
        try:
            LeprikonSite.objects.get_current()
        except:
            pass

        # create leprikon page on first run
        from cms.api import create_page
        from cms.constants import TEMPLATE_INHERITANCE_MAGIC
        from menus.menu_pool import menu_pool
        from .conf import settings
        try:
            create_page(
                title='Leprikón',
                template=TEMPLATE_INHERITANCE_MAGIC,
                language=settings.LANGUAGE_CODE,
                slug='leprikon',
                apphook='LeprikonApp',
                apphook_namespace='leprikon',
                reverse_id='leprikon',
                in_navigation=True,
                navigation_extenders='LeprikonMenu',
                published=True,
            ).set_as_homepage()
            menu_pool.clear()
        except:
            pass
开发者ID:leprikon-cz,项目名称:leprikon,代码行数:30,代码来源:apps.py


示例2: pre_save_title

def pre_save_title(instance, raw, **kwargs):
    """Save old state to instance and setup path
    """
    if instance.page.languages:
        languages = instance.page.languages.split(',')
    else:
        languages = []
    if not instance.language in languages:
        languages.append(instance.language)
        instance.page.languages = ",".join(languages)
        instance.page._publisher_keep_state = True
        instance.page.save(no_signals=True)
    if not instance.page.publisher_is_draft:
        menu_pool.clear(instance.page.site_id)
    if instance.pk and not hasattr(instance, "tmp_path"):
        instance.tmp_path = None
        try:
            instance.tmp_path = Title.objects.filter(pk=instance.pk).values_list('path')[0][0]
        except IndexError:
            pass  # no Titles exist for this page yet
    # Build path from parent page's path and slug
    if instance.has_url_overwrite and instance.path:
        instance.path = instance.path.strip(" /")
    else:
        update_title(instance)
    apphook_pre_title_checker(instance, **kwargs)
开发者ID:1oscar,项目名称:django-cms,代码行数:26,代码来源:title.py


示例3: process_request

 def process_request(self, request):
     """
     If we should show the toolbar for this request, put it on
     request.toolbar. Then call the request_hook on the toolbar.
     """
     if 'edit' in request.GET and not request.session.get('cms_edit', False):
         if not request.session.get('cms_edit', False):
             menu_pool.clear()
         request.session['cms_edit'] = True
         if request.session.get('cms_build', False):
             request.session['cms_build'] = False
     if 'edit_off' in request.GET and request.session.get('cms_edit', True):
         if request.session.get('cms_edit', True):
             menu_pool.clear()
         request.session['cms_edit'] = False
         if request.session.get('cms_build', False):
             request.session['cms_build'] = False
     if 'build' in request.GET and not request.session.get('cms_build', False):
         request.session['cms_build'] = True
     if request.user.is_staff:
         try:
             request.cms_latest_entry = LogEntry.objects.filter(
                 user=request.user,
                 action_flag__in=(ADDITION, CHANGE)
             ).only('pk').order_by('-pk')[0].pk
         except IndexError:
             request.cms_latest_entry = -1
     request.toolbar = CMSToolbar(request)
开发者ID:Acidburn0zzz,项目名称:django-cms,代码行数:28,代码来源:toolbar.py


示例4: test_15_home_not_in_menu

 def test_15_home_not_in_menu(self):
     with SettingsOverride(CMS_MODERATOR=False):
 
         page1 = Page.objects.get(pk=self.page1.pk)
         page1.in_navigation = False
         page1.save()
         page4 = Page.objects.get(pk=self.page4.pk)
         page4.in_navigation = False
         page4.save()
         context = self.get_context()
         tpl = Template("{% load menu_tags %}{% show_menu 0 100 100 100 %}")
         tpl.render(context) 
         nodes = context['children']
         self.assertEqual(len(nodes), 1)
         self.assertEqual(nodes[0].get_absolute_url(), "%s%s/" % (self.get_pages_root(), self.page2.get_slug()))
         self.assertEqual(nodes[0].children[0].get_absolute_url(), "%s%s/%s/" % (self.get_pages_root(), self.page2.get_slug(), self.page3.get_slug()))
         page4 = Page.objects.get(pk=self.page4.pk)
         page4.in_navigation = True
         page4.save()
         menu_pool.clear(settings.SITE_ID)
         context = self.get_context()
         tpl = Template("{% load menu_tags %}{% show_menu 0 100 100 100 %}")
         tpl.render(context) 
         nodes = context['children']
         self.assertEqual(len(nodes), 2)
开发者ID:CreativeCubes,项目名称:django-cms,代码行数:25,代码来源:menu.py


示例5: pre_save_title

def pre_save_title(instance, raw, **kwargs):
    """Save old state to instance and setup path
    """
    
    menu_pool.clear(instance.page.site_id)
    
    instance.tmp_path = None
    instance.tmp_application_urls = None
    
    if instance.id:
        try:
            tmp_title = Title.objects.get(pk=instance.id)
            instance.tmp_path = tmp_title.path
            instance.tmp_application_urls = tmp_title.application_urls
        except:
            pass # no Titles exist for this page yet
    
    # Build path from parent page's path and slug
    if instance.has_url_overwrite and instance.path:
        instance.path = instance.path.strip(" /")
    else:
        parent_page = instance.page.parent
        slug = u'%s' % instance.slug
        
        instance.path = u'%s' % slug
        if parent_page:
            parent_title = Title.objects.get_title(parent_page, language=instance.language, language_fallback=True)
            if parent_title:
                instance.path = (u'%s/%s' % (parent_title.path, slug)).lstrip("/")
开发者ID:BeUnique,项目名称:django-cms,代码行数:29,代码来源:signals.py


示例6: setUp

 def setUp(self):
     super(BaseMenuTest, self).setUp()
     if not menu_pool.discovered:
         menu_pool.discover_menus()
     self.old_menu = menu_pool.menus
     menu_pool.menus = {'CMSMenu': self.old_menu['CMSMenu']}
     menu_pool.clear(settings.SITE_ID)
开发者ID:Air51,项目名称:django-cms,代码行数:7,代码来源:menu.py


示例7: pre_save_title

def pre_save_title(instance, raw, **kwargs):
    """Save old state to instance and setup path
    """
    page = instance.page
    page_languages = page.get_languages()

    if not instance.language in page_languages:
        page_languages.append(instance.language)
        page.update_languages(page_languages)

    if not page.publisher_is_draft:
        menu_pool.clear(page.site_id)

    if instance.pk and not hasattr(instance, "tmp_path"):
        instance.tmp_path = None
        try:
            instance.tmp_path = Title.objects.filter(pk=instance.pk).values_list("path")[0][0]
        except IndexError:
            pass  # no Titles exist for this page yet
    # Build path from parent page's path and slug
    if instance.has_url_overwrite and instance.path:
        instance.path = instance.path.strip(" /")
    else:
        update_title(instance)
    apphook_pre_title_checker(instance, **kwargs)
开发者ID:nimbis,项目名称:django-cms,代码行数:25,代码来源:title.py


示例8: pre_delete_page

def pre_delete_page(instance, **kwargs):
    menu_pool.clear(instance.site_id)
    for placeholder in instance.placeholders.all():
        for plugin in placeholder.cmsplugin_set.all():
            plugin._no_reorder = True
            plugin.delete()
        placeholder.delete()
    clear_permission_cache()
开发者ID:Konviser,项目名称:django-cms,代码行数:8,代码来源:page.py


示例9: test_incorrect_nav_extender_in_db

 def test_incorrect_nav_extender_in_db(self):
     self._update_page(2, navigation_extenders="SomethingWrong")
     menu_pool.clear(settings.SITE_ID)
     context = self.get_context()
     tpl = Template("{% load menu_tags %}{% show_menu %}")
     tpl.render(context)
     nodes = context["children"]
     self.assertEqual(len(nodes), 2)
开发者ID:alainwolf,项目名称:openbroadcast.org,代码行数:8,代码来源:navextender.py


示例10: pre_save_page

def pre_save_page(instance, **kwargs):
    instance.old_page = None
    try:
        instance.old_page = Page.objects.get(pk=instance.pk)
    except ObjectDoesNotExist:
        pass
    menu_pool.clear(instance.site_id)
    clear_permission_cache()
开发者ID:Konviser,项目名称:django-cms,代码行数:8,代码来源:page.py


示例11: pre_delete_page

def pre_delete_page(instance, **kwargs):
    menu_pool.clear(instance.site_id)
    for placeholder in instance.get_placeholders():
        for plugin in placeholder.cmsplugin_set.all().order_by('-depth'):
            plugin._no_reorder = True
            plugin.delete(no_mp=True)
        placeholder.delete()
    clear_permission_cache()
开发者ID:AaronJaramillo,项目名称:shopDPM,代码行数:8,代码来源:page.py


示例12: save_model

 def save_model(self, request, obj, form, change):
     """
     Clear menu cache when changing menu structure
     """
     if 'config.menu_structure' in form.changed_data:
         from menus.menu_pool import menu_pool
         menu_pool.clear(all=True)
     return super(BlogConfigAdmin, self).save_model(request, obj, form, change)
开发者ID:cnk-digital-solutions,项目名称:djangocms-blog,代码行数:8,代码来源:admin.py


示例13: test_extenders_on_root_child

 def test_extenders_on_root_child(self):
     self._update_page(4, navigation_extenders="TestMenu")
     menu_pool.clear(settings.SITE_ID)
     context = self.get_context()
     tpl = Template("{% load menu_tags %}{% show_menu 0 100 100 100 %}")
     tpl.render(context)
     nodes = context["children"]
     self.assertEqual(len(nodes), 2)
     self.assertEqual(len(nodes[1].children), 4)
开发者ID:alainwolf,项目名称:openbroadcast.org,代码行数:9,代码来源:navextender.py


示例14: pre_save_page

def pre_save_page(instance, raw, **kwargs):
    """Helper pre save signal, assigns old_page attribute, so we can still
    compare changes. Currently used only if CMS_PUBLISHER
    """
    menu_pool.clear(instance.site_id)
    instance.old_page = None
    try:
        instance.old_page = Page.objects.get(pk=instance.pk)
    except ObjectDoesNotExist:
        pass
开发者ID:beloblotskiy,项目名称:django-cms-2.0,代码行数:10,代码来源:signals.py


示例15: setUp

 def setUp(self):
     super(BaseMenuTest, self).setUp()
     u = User(username="test", is_staff = True, is_active = True, is_superuser = True)
     u.set_password("test")
     u.save()
     self.login_user(u)
     if not menu_pool.discovered:
         menu_pool.discover_menus()
     self.old_menu = menu_pool.menus
     menu_pool.menus = {'CMSMenu':self.old_menu['CMSMenu']}
     menu_pool.clear(settings.SITE_ID)
开发者ID:AdrianRibao,项目名称:django-cms,代码行数:11,代码来源:menu.py


示例16: setUp

 def setUp(self):
     settings.CMS_MODERATOR = False
     u = User(username="test", is_staff = True, is_active = True, is_superuser = True)
     u.set_password("test")
     u.save()
     self.login_user(u)
     if not menu_pool.discovered:
         menu_pool.discover_menus()
     self.old_menu = menu_pool.menus
     menu_pool.menus = {'CMSMenu':self.old_menu['CMSMenu']}
     menu_pool.clear(settings.SITE_ID)
     self.create_some_nodes()
开发者ID:DrMeers,项目名称:django-cms-2.0,代码行数:12,代码来源:menu.py


示例17: setUp

 def setUp(self):
     
     with SettingsOverride(CMS_MODERATOR = False):
         u = User(username="test", is_staff = True, is_active = True, is_superuser = True)
         u.set_password("test")
         u.save()
         self.login_user(u)
         menu_pool.clear(settings.SITE_ID)
         
         if not menu_pool.discovered:
             menu_pool.discover_menus()
         self.old_menu = menu_pool.menus
         menu_pool.menus = {'CMSMenu':self.old_menu['CMSMenu'], 'TestMenu':TestMenu()}
开发者ID:42,项目名称:django-cms,代码行数:13,代码来源:navextender.py


示例18: process_request

    def process_request(self, request):
        """
        If we should show the toolbar for this request, put it on
        request.toolbar. Then call the request_hook on the toolbar.
        """

        if not self.is_cms_request(request):
            return

        edit_on = get_cms_setting('CMS_TOOLBAR_URL__EDIT_ON')
        edit_off = get_cms_setting('CMS_TOOLBAR_URL__EDIT_OFF')
        build = get_cms_setting('CMS_TOOLBAR_URL__BUILD')
        disable = get_cms_setting('CMS_TOOLBAR_URL__DISABLE')
        anonymous_on = get_cms_setting('TOOLBAR_ANONYMOUS_ON')

        if disable in request.GET:
            request.session['cms_toolbar_disabled'] = True
        if edit_on in request.GET:  # If we actively enter edit mode, we should show the toolbar in any case
            request.session['cms_toolbar_disabled'] = False

        if not request.session.get('cms_toolbar_disabled', False) and (
                request.user.is_staff or (anonymous_on and request.user.is_anonymous())
        ):
            if edit_on in request.GET and not request.session.get('cms_edit', False):
                if not request.session.get('cms_edit', False):
                    menu_pool.clear()
                request.session['cms_edit'] = True
                if request.session.get('cms_build', False):
                    request.session['cms_build'] = False
            if edit_off in request.GET and request.session.get('cms_edit', True):
                if request.session.get('cms_edit', True):
                    menu_pool.clear()
                request.session['cms_edit'] = False
                if request.session.get('cms_build', False):
                    request.session['cms_build'] = False
            if build in request.GET and not request.session.get('cms_build', False):
                request.session['cms_build'] = True
        else:
            if request.session.get('cms_build'):
                request.session['cms_build'] = False
            if request.session.get('cms_edit'):
                request.session['cms_edit'] = False
        if request.user.is_staff:
            try:
                request.cms_latest_entry = LogEntry.objects.filter(
                    user=request.user,
                    action_flag__in=(ADDITION, CHANGE)
                ).only('pk').order_by('-pk')[0].pk
            except IndexError:
                request.cms_latest_entry = -1
        request.toolbar = CMSToolbar(request)
开发者ID:evildmp,项目名称:django-cms,代码行数:51,代码来源:toolbar.py


示例19: test_extenders_on_child

 def test_extenders_on_child(self):
     """
     TestMenu has 4 flat nodes
     """
     self._update_page(1, in_navigation=False)
     self._update_page(2, navigation_extenders="TestMenu")
     menu_pool.clear(settings.SITE_ID)
     menu_pool.clear(settings.SITE_ID)
     context = self.get_context()
     tpl = Template("{% load menu_tags %}{% show_menu 0 100 100 100 %}")
     tpl.render(context)
     nodes = context["children"]
     self.assertEqual(len(nodes), 2)
     self.assertEqual(len(nodes[0].children), 4)
     self.assertEqual(nodes[0].children[1].get_absolute_url(), "/")
开发者ID:alainwolf,项目名称:openbroadcast.org,代码行数:15,代码来源:navextender.py


示例20: test_02_extenders_on_root

    def test_02_extenders_on_root(self):
        Page.objects.filter(pk=1).update(navigation_extenders="TestMenu")
        menu_pool.clear(settings.SITE_ID)
        context = self.get_context()

        tpl = Template("{% load menu_tags %}{% show_menu 0 100 100 100 %}")
        tpl.render(context)
        nodes = context["children"]
        self.assertEqual(len(nodes), 2)
        self.assertEqual(len(nodes[0].children), 4)
        self.assertEqual(len(nodes[0].children[3].children), 1)
        Page.objects.filter(pk=1).update(in_navigation=False)
        menu_pool.clear(settings.SITE_ID)
        tpl = Template("{% load menu_tags %}{% show_menu %}")
        tpl.render(context)
        nodes = context["children"]
        self.assertEqual(len(nodes), 5)
开发者ID:BeUnique,项目名称:django-cms,代码行数:17,代码来源:navextender.py



注:本文中的menus.menu_pool.menu_pool.clear函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python menu_pool.discover_menus函数代码示例发布时间:2022-05-27
下一篇:
Python menu_pool.apply_modifiers函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap