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


Python helpers.validate_template函数代码示例

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


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

示例1: test_deactivate_validate_template

 def test_deactivate_validate_template(self):
     with SettingsOverride(SEKIZAI_IGNORE_VALIDATION=True):
         self.assertTrue(validate_template('basic.html', ['js', 'css']))
         self.assertTrue(validate_template('basic.html', ['js']))
         self.assertTrue(validate_template('basic.html', ['css']))
         self.assertTrue(validate_template('basic.html', []))
         self.assertTrue(validate_template('basic.html', ['notfound']))
开发者ID:amaozhao,项目名称:chaoqianpipes,代码行数:7,代码来源:tests.py

示例2: check_sekizai

def check_sekizai(output):
    with output.section("Sekizai") as section:
        if is_installed('sekizai'):
            section.success("Sekizai is installed")
        else:
            section.error("Sekizai is not installed, could not find 'sekizai' in INSTALLED_APPS")
        if DJANGO_1_7:
            if 'sekizai.context_processors.sekizai' in settings.TEMPLATE_CONTEXT_PROCESSORS:
                section.success("Sekizai template context processor is installed")
            else:
                section.error("Sekizai template context processor is not installed, could not find 'sekizai.context_processors.sekizai' in TEMPLATE_CONTEXT_PROCESSORS")
        else:
            processors = list(chain(*[template['OPTIONS'].get('context_processors', []) for template in settings.TEMPLATES]))
            if 'sekizai.context_processors.sekizai' in processors:
                section.success("Sekizai template context processor is installed")
            else:
                section.error("Sekizai template context processor is not installed, could not find 'sekizai.context_processors.sekizai' in TEMPLATES option context_processors")

        for template, _ in get_cms_setting('TEMPLATES'):
            if template == constants.TEMPLATE_INHERITANCE_MAGIC:
                continue
            if validate_template(template, ['js', 'css']):
                section.success("Sekizai namespaces 'js' and 'css' found in %r" % template)
            else:
                section.error("Sekizai namespaces 'js' and 'css' not found in %r" % template)
        if section.successful:
            section.finish_success("Sekizai configuration okay")
        else:
            section.finish_error("Sekizai configuration has errors")
开发者ID:alegrm,项目名称:django-cms,代码行数:29,代码来源:check.py

示例3: check_sekizai

def check_sekizai(output):
    with output.section("Sekizai") as section:
        sekizai_installed = is_installed('sekizai')

        if sekizai_installed:
            section.success("Sekizai is installed")
        else:
            section.error("Sekizai is not installed, could not find 'sekizai' in INSTALLED_APPS")
        processors = list(
            chain(*[template['OPTIONS'].get('context_processors', []) for template in settings.TEMPLATES]))
        if 'sekizai.context_processors.sekizai' in processors:
            section.success("Sekizai template context processor is installed")
        else:
            section.error("Sekizai template context processor is not installed, could not find "
                          "'sekizai.context_processors.sekizai' in TEMPLATES option context_processors")

        if not sekizai_installed:
            # sekizai is not installed.
            # we can't reliable check templates
            # because template loading won't work
            return

        for template, _ in get_cms_setting('TEMPLATES'):
            if template == constants.TEMPLATE_INHERITANCE_MAGIC:
                continue
            if validate_template(template, ['js', 'css']):
                section.success("Sekizai namespaces 'js' and 'css' found in %r" % template)
            else:
                section.error("Sekizai namespaces 'js' and 'css' not found in %r" % template)
        if section.successful:
            section.finish_success("Sekizai configuration okay")
        else:
            section.finish_error("Sekizai configuration has errors")
开发者ID:janwilliams,项目名称:CMS,代码行数:33,代码来源:check.py

示例4: post_patch_check

def post_patch_check():
    """Post patch check, just make sure there isn't any misconfiguration. All
    the code for checking settings should go here.
    """

    # Ensure templates are set, and more than just the inheritance setting.
    cms_templates_length = len(settings.CMS_TEMPLATES)
    if (cms_templates_length < 1 or
        (cms_templates_length == 1 and settings.CMS_TEMPLATES[0][0] == settings.CMS_TEMPLATE_INHERITANCE_MAGIC)):
        raise ImproperlyConfigured('Please make sure you specified a CMS_TEMPLATES setting.')
    
    # check if is user middleware installed
    if settings.CMS_PERMISSION and not 'cms.middleware.user.CurrentUserMiddleware' in settings.MIDDLEWARE_CLASSES:
        raise ImproperlyConfigured('CMS Permission system requires cms.middleware.user.CurrentUserMiddleware.\n'
            'Please put it into your MIDDLEWARE_CLASSES in settings file')
    
    # check sekizai namespaces
    try:
        from django.template.loaders.app_directories import Loader
    except ImportError:
        return # south...
    for template in settings.CMS_TEMPLATES:
        if template[0] == settings.CMS_TEMPLATE_INHERITANCE_MAGIC:
            continue
        if not validate_template(template[0], ['js', 'css']):
            raise ImproperlyConfigured(
                "The 'js' and 'css' sekizai namespaces must be present in each template, "
                "- or a template it inherits from - defined in CMS_TEMPLATES. "
                "I can't find the namespaces in %r."
                % template[0]
            )
开发者ID:AlexMarshall12,项目名称:django-cms,代码行数:31,代码来源:patch.py

示例5: test_validate_template_notfound

 def test_validate_template_notfound(self):
     self.assertFalse(validate_template('basic.html', ['notfound']))
开发者ID:amaozhao,项目名称:chaoqianpipes,代码行数:2,代码来源:tests.py

示例6: test_validate_template_empty

 def test_validate_template_empty(self):
     self.assertTrue(validate_template('basic.html', []))
开发者ID:amaozhao,项目名称:chaoqianpipes,代码行数:2,代码来源:tests.py

示例7: test_validate_template_css

 def test_validate_template_css(self):
     self.assertTrue(validate_template('basic.html', ['css']))
开发者ID:amaozhao,项目名称:chaoqianpipes,代码行数:2,代码来源:tests.py

示例8: test_validate_template

 def test_validate_template(self):
     self.assertTrue(validate_template('basic.html', ['js', 'css']))
     self.assertTrue(validate_template('basic.html', ['js']))
     self.assertTrue(validate_template('basic.html', ['css']))
     self.assertTrue(validate_template('basic.html', []))
     self.assertFalse(validate_template('basic.html', ['notfound']))
开发者ID:nephila,项目名称:django-sekizai,代码行数:6,代码来源:tests.py

示例9: validate_test_template

def validate_test_template(*args, **kwargs):
    return validate_template(*args, **kwargs)
开发者ID:benjaoming,项目名称:django-sekizai,代码行数:2,代码来源:tests.py

示例10: test_validate_template_js

 def test_validate_template_js(self):
     self.assertTrue(validate_template('sekizai_tests/basic.html', ['js']))
开发者ID:digi604,项目名称:django-sekizai,代码行数:2,代码来源:tests.py


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