本文整理汇总了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
示例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)
示例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)
示例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)
示例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("/")
示例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)
示例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)
示例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()
示例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)
示例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()
示例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()
示例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)
示例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)
示例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
示例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)