当前位置: 首页>>代码示例>>Python>>正文


Python menu_pool.clear函数代码示例

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


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


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