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


Python PlaceholderNode.save方法代码示例

本文整理汇总了Python中pages.placeholders.PlaceholderNode.save方法的典型用法代码示例。如果您正苦于以下问题:Python PlaceholderNode.save方法的具体用法?Python PlaceholderNode.save怎么用?Python PlaceholderNode.save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pages.placeholders.PlaceholderNode的用法示例。


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

示例1: test_placeholder_name_space_bug

# 需要导入模块: from pages.placeholders import PlaceholderNode [as 别名]
# 或者: from pages.placeholders.PlaceholderNode import save [as 别名]
    def test_placeholder_name_space_bug(self):
        """Cache key cannot us space."""
        from pages.placeholders import PlaceholderNode

        page = self.new_page()
        placeholder = PlaceholderNode("test space", page=page)
        placeholder.save(page, "fr-ch", "fr", True)
        self.assertEqual(Content.objects.get_content(page, "fr-ch", placeholder.ctype), "fr")
开发者ID:egorius,项目名称:django-page-cms,代码行数:10,代码来源:test_regression.py

示例2: test_placeholder_name_space_bug

# 需要导入模块: from pages.placeholders import PlaceholderNode [as 别名]
# 或者: from pages.placeholders.PlaceholderNode import save [as 别名]
 def test_placeholder_name_space_bug(self):
     """Cache key cannot us space."""
     from pages.placeholders import PlaceholderNode
     page = self.new_page()
     placeholder = PlaceholderNode('test space', page=page)
     placeholder.save(page, 'fr-ch', 'fr', True)
     self.assertEqual(
         Content.objects.get_content(page, 'fr-ch', 'test space'),
         'fr'
     )
开发者ID:gerram,项目名称:django-page-cms,代码行数:12,代码来源:test_regression.py

示例3: test_placeholder_cache_bug

# 需要导入模块: from pages.placeholders import PlaceholderNode [as 别名]
# 或者: from pages.placeholders.PlaceholderNode import save [as 别名]
    def test_placeholder_cache_bug(self):
        """There was an bad bug caused when the page cache was filled
        the first time."""
        from pages.placeholders import PlaceholderNode

        page = self.new_page()
        placeholder = PlaceholderNode("test", page=page)
        placeholder.save(page, "fr-ch", "fr", True)
        placeholder.save(page, "en-us", "en", True)
        self.assertEqual(Content.objects.get_content(page, "fr-ch", "test"), "fr")
开发者ID:egorius,项目名称:django-page-cms,代码行数:12,代码来源:test_regression.py

示例4: test_placeholder_name_space_bug_with_template

# 需要导入模块: from pages.placeholders import PlaceholderNode [as 别名]
# 或者: from pages.placeholders.PlaceholderNode import save [as 别名]
 def test_placeholder_name_space_bug_with_template(self):
     """
     Template space test
     """
     from pages.placeholders import PlaceholderNode
     page = self.new_page()
     placeholder = PlaceholderNode('hello world', page=page)
     placeholder.save(page, 'fr-ch', 'hello!', True)
     context = Context({'current_page': page, 'lang':'fr-ch'})
     pl1 = """{% load pages_tags %}{% placeholder "hello world" %}"""
     template = self.get_template_from_string(pl1)
     self.assertEqual(template.render(context), 'hello!')
开发者ID:DjangoBD,项目名称:django-page-cms,代码行数:14,代码来源:test_regression.py

示例5: test_placeholder_cache_bug

# 需要导入模块: from pages.placeholders import PlaceholderNode [as 别名]
# 或者: from pages.placeholders.PlaceholderNode import save [as 别名]
 def test_placeholder_cache_bug(self):
     """There was an bad bug caused when the page cache was filled
     the first time."""
     from pages.placeholders import PlaceholderNode
     page = self.new_page()
     placeholder = PlaceholderNode('test', page=page)
     placeholder.save(page, 'fr-ch', 'fr', True)
     placeholder.save(page, 'en-us', 'en', True)
     self.assertEqual(
         Content.objects.get_content(page, 'fr-ch', 'test'),
         'fr'
     )
开发者ID:DjangoBD,项目名称:django-page-cms,代码行数:14,代码来源:test_regression.py

示例6: test_placeholder_name_space_bug_with_template

# 需要导入模块: from pages.placeholders import PlaceholderNode [as 别名]
# 或者: from pages.placeholders.PlaceholderNode import save [as 别名]
    def test_placeholder_name_space_bug_with_template(self):
        """
        Template space test
        """
        from pages.placeholders import PlaceholderNode

        page = self.new_page()
        placeholder = PlaceholderNode("hello world", page=page)
        placeholder.save(page, "fr-ch", "hello!", True)
        context = Context({"current_page": page, "lang": "fr-ch"})
        pl1 = """{% load pages_tags %}{% placeholder "hello world" %}"""
        template = self.get_template_from_string(pl1)
        self.assertEqual(template.render(context), "hello!")
开发者ID:egorius,项目名称:django-page-cms,代码行数:15,代码来源:test_regression.py

示例7: test_placeholder_untranslated_content

# 需要导入模块: from pages.placeholders import PlaceholderNode [as 别名]
# 或者: from pages.placeholders.PlaceholderNode import save [as 别名]
    def test_placeholder_untranslated_content(self):
        """Test placeholder untranslated content."""
        from pages import settings as pages_settings
        setattr(pages_settings, "PAGE_USE_SITE_ID", False)
        author = User.objects.all()[0]
        page = Page(author=author, status=Page.PUBLISHED)
        page.save()
        placeholder = PlaceholderNode('untrans', page='p', untranslated=True)
        placeholder.save(page, 'fr-ch', 'test-content', True)
        placeholder.save(page, 'en-us', 'test-content', True)
        self.assertEqual(len(Content.objects.all()), 1)
        self.assertEqual(Content.objects.all()[0].language, 'en-us')

        placeholder = PlaceholderNode('untrans', page='p', untranslated=False)
        placeholder.save(page, 'fr-ch', 'test-content', True)
        self.assertEqual(len(Content.objects.all()), 2)
开发者ID:k1000,项目名称:django-page-cms,代码行数:18,代码来源:pages_tests.py

示例8: test_placeholder_quoted_name

# 需要导入模块: from pages.placeholders import PlaceholderNode [as 别名]
# 或者: from pages.placeholders.PlaceholderNode import save [as 别名]
    def test_placeholder_quoted_name(self):
        """Test placeholder name with quotes."""
        page = self.new_page()
        context = {'current_page': page, 'lang': 'en-us'}
        placeholder = PlaceholderNode("test name")
        placeholder.save(page, 'en-us', 'some random value', False)

        pl1 = """{% load pages_tags %}{% placeholder "test name" as hello %}{{ hello }}"""
        template = self.get_template_from_string(pl1)
        self.assertEqual(render(template, context), 'some random value')

        placeholder = PlaceholderNode("with accent éàè")
        placeholder.save(page, 'en-us', 'some random value', False)

        pl1 = """{% load pages_tags %}{% placeholder "with accent éàè" as hello %}{{ hello }}"""
        template = self.get_template_from_string(pl1)
        self.assertEqual(render(template, context), 'some random value')
开发者ID:DjangoBD,项目名称:django-page-cms,代码行数:19,代码来源:test_templates.py

示例9: test_placeholder_quoted_name

# 需要导入模块: from pages.placeholders import PlaceholderNode [as 别名]
# 或者: from pages.placeholders.PlaceholderNode import save [as 别名]
    def test_placeholder_quoted_name(self):
        """Test placeholder name with quotes."""
        page = self.new_page()
        context = Context({"current_page": page, "lang": "en-us"})
        placeholder = PlaceholderNode("test name")
        placeholder.save(page, "en-us", "some random value", False)

        pl1 = """{% load pages_tags %}{% placeholder "test name" as hello %}{{ hello }}"""
        template = self.get_template_from_string(pl1)
        self.assertEqual(template.render(context), "some random value")

        placeholder = PlaceholderNode("with accent éàè")
        placeholder.save(page, "en-us", "some random value", False)

        pl1 = """{% load pages_tags %}{% placeholder "with accent éàè" as hello %}{{ hello }}"""
        template = self.get_template_from_string(pl1)
        self.assertEqual(template.render(context), "some random value")
开发者ID:asd1355215911,项目名称:django-page-cms,代码行数:19,代码来源:test_unit.py

示例10: test_placeholder_untranslated_content

# 需要导入模块: from pages.placeholders import PlaceholderNode [as 别名]
# 或者: from pages.placeholders.PlaceholderNode import save [as 别名]
    def test_placeholder_untranslated_content(self):
        """Test placeholder untranslated content."""
        self.set_setting("PAGE_USE_SITE_ID", False)
        page = self.new_page(content={})
        placeholder = PlaceholderNode("untrans", page="p", untranslated=True)
        placeholder.save(page, "fr-ch", "test-content", True)
        placeholder.save(page, "en-us", "test-content", True)
        self.assertEqual(len(Content.objects.all()), 1)
        self.assertEqual(Content.objects.all()[0].language, "en-us")

        placeholder = PlaceholderNode("untrans", page="p", untranslated=False)
        placeholder.save(page, "fr-ch", "test-content", True)
        self.assertEqual(len(Content.objects.all()), 2)

        # test the syntax
        page = self.new_page()
        template = django.template.loader.get_template("pages/tests/untranslated.html")
        context = Context({"current_page": page, "lang": "en-us"})
        self.assertEqual(template.render(context), "")
开发者ID:asd1355215911,项目名称:django-page-cms,代码行数:21,代码来源:test_unit.py

示例11: test_placeholder_untranslated_content

# 需要导入模块: from pages.placeholders import PlaceholderNode [as 别名]
# 或者: from pages.placeholders.PlaceholderNode import save [as 别名]
    def test_placeholder_untranslated_content(self):
        """Test placeholder untranslated content."""
        self.set_setting("PAGE_USE_SITE_ID", False)
        page = self.new_page(content={})
        placeholder = PlaceholderNode('untrans', page='p', untranslated=True)
        placeholder.save(page, 'fr-ch', 'test-content', True)
        placeholder.save(page, 'en-us', 'test-content', True)
        self.assertEqual(len(Content.objects.all()), 1)
        self.assertEqual(Content.objects.all()[0].language, 'en-us')

        placeholder = PlaceholderNode('untrans', page='p', untranslated=False)
        placeholder.save(page, 'fr-ch', 'test-content', True)
        self.assertEqual(len(Content.objects.all()), 2)

        # test the syntax
        page = self.new_page()
        template = django.template.loader.get_template(
                'pages/tests/untranslated.html')
        context = {'current_page': page, 'lang': 'en-us'}
        self.assertEqual(render(template, context), '')
开发者ID:DjangoBD,项目名称:django-page-cms,代码行数:22,代码来源:test_templates.py


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