本文整理汇总了Python中django.template.library.InvalidTemplateLibrary方法的典型用法代码示例。如果您正苦于以下问题:Python library.InvalidTemplateLibrary方法的具体用法?Python library.InvalidTemplateLibrary怎么用?Python library.InvalidTemplateLibrary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.template.library
的用法示例。
在下文中一共展示了library.InvalidTemplateLibrary方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_package_libraries
# 需要导入模块: from django.template import library [as 别名]
# 或者: from django.template.library import InvalidTemplateLibrary [as 别名]
def get_package_libraries(pkg):
"""
Recursively yield template tag libraries defined in submodules of a
package.
"""
for entry in walk_packages(pkg.__path__, pkg.__name__ + '.'):
try:
module = import_module(entry[1])
except ImportError as e:
raise InvalidTemplateLibrary(
"Invalid template library specified. ImportError raised when "
"trying to load '%s': %s" % (entry[1], e)
)
if hasattr(module, 'register'):
yield entry[1]
示例2: test_load_error
# 需要导入模块: from django.template import library [as 别名]
# 或者: from django.template.library import InvalidTemplateLibrary [as 别名]
def test_load_error(self):
msg = (
"Invalid template library specified. ImportError raised when "
"trying to load 'template_tests.broken_tag': cannot import name "
"'Xtemplate'"
)
with self.assertRaisesMessage(InvalidTemplateLibrary, msg):
Engine(libraries={'broken_tag': 'template_tests.broken_tag'})
示例3: test_load_error_egg
# 需要导入模块: from django.template import library [as 别名]
# 或者: from django.template.library import InvalidTemplateLibrary [as 别名]
def test_load_error_egg(self):
egg_name = '%s/tagsegg.egg' % self.egg_dir
msg = (
"Invalid template library specified. ImportError raised when "
"trying to load 'tagsegg.templatetags.broken_egg': cannot "
"import name 'Xtemplate'"
)
with extend_sys_path(egg_name):
with self.assertRaisesMessage(InvalidTemplateLibrary, msg):
Engine(libraries={'broken_egg': 'tagsegg.templatetags.broken_egg'})