當前位置: 首頁>>代碼示例>>Python>>正文


Python template.Origin方法代碼示例

本文整理匯總了Python中django.template.Origin方法的典型用法代碼示例。如果您正苦於以下問題:Python template.Origin方法的具體用法?Python template.Origin怎麽用?Python template.Origin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.template的用法示例。


在下文中一共展示了template.Origin方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_template_sources

# 需要導入模塊: from django import template [as 別名]
# 或者: from django.template import Origin [as 別名]
def get_template_sources(self, template_name):
        """
        Return an Origin object pointing to an absolute path in each directory
        in template_dirs. For security reasons, if a path doesn't lie inside
        one of the template_dirs it is excluded from the result set.
        """
        for template_dir in self.get_dirs():
            try:
                name = safe_join(template_dir, template_name)
            except SuspiciousFileOperation:
                # The joined path was located outside of this template_dir
                # (it might be inside another one, so this isn't fatal).
                continue

            yield Origin(
                name=name,
                template_name=template_name,
                loader=self,
            ) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:21,代碼來源:filesystem.py

示例2: get_template_sources

# 需要導入模塊: from django import template [as 別名]
# 或者: from django.template import Origin [as 別名]
def get_template_sources(self, template_name, template_dirs=None):
        """
        Return an Origin object pointing to an absolute path in each directory
        in template_dirs. For security reasons, if a path doesn't lie inside
        one of the template_dirs it is excluded from the result set.
        """
        if not template_dirs:
            template_dirs = self.get_dirs()
        for template_dir in template_dirs:
            try:
                name = safe_join(template_dir, template_name)
            except SuspiciousFileOperation:
                # The joined path was located outside of this template_dir
                # (it might be inside another one, so this isn't fatal).
                continue

            yield Origin(
                name=name,
                template_name=template_name,
                loader=self,
            ) 
開發者ID:BirkbeckCTP,項目名稱:janeway,代碼行數:23,代碼來源:template_override_middleware.py

示例3: load_template

# 需要導入模塊: from django import template [as 別名]
# 或者: from django.template import Origin [as 別名]
def load_template(self, template_name, template_dirs=None):
        warnings.warn(
            'The load_template() method is deprecated. Use get_template() '
            'instead.', RemovedInDjango20Warning,
        )
        source, display_name = self.load_template_source(
            template_name, template_dirs,
        )
        origin = Origin(
            name=display_name,
            template_name=template_name,
            loader=self,
        )
        try:
            template = Template(source, origin, template_name, self.engine)
        except TemplateDoesNotExist:
            # If compiling the template we found raises TemplateDoesNotExist,
            # back off to returning the source and display name for the
            # template we were asked to load. This allows for correct
            # identification of the actual template that does not exist.
            return source, display_name
        else:
            return template, None 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:25,代碼來源:base.py

示例4: get_template_sources

# 需要導入模塊: from django import template [as 別名]
# 或者: from django.template import Origin [as 別名]
def get_template_sources(self, template_name, template_dirs=None):
        """
        Returns the absolute paths to "template_name" in the specified app.
        If the name does not contain an app name (no colon), an empty list
        is returned.
        The parent FilesystemLoader.load_template_source() will take care
        of the actual loading for us.
        """
        if ':' not in template_name:
            return []
        app_name, template_name = template_name.split(":", 1)
        template_dir = get_app_template_dir(app_name)
        if template_dir:
            try:
                from django.template import Origin
                origin = Origin(
                    name=join(template_dir, template_name),
                    template_name=template_name,
                    loader=self,
                )
            except (ImportError, TypeError):
                origin = join(template_dir, template_name)
            return [origin]
        return [] 
開發者ID:django-admin-tools,項目名稱:django-admin-tools,代碼行數:26,代碼來源:template_loaders.py

示例5: get_template_sources

# 需要導入模塊: from django import template [as 別名]
# 或者: from django.template import Origin [as 別名]
def get_template_sources(self, template_name, template_dirs=None):
        """
        Return an Origin object pointing to an absolute path in each directory
        in template_dirs. For security reasons, if a path doesn't lie inside
        one of the template_dirs it is excluded from the result set.
        """
        if not template_dirs:
            template_dirs = get_directories_in_tethys(('templates',))
        for template_dir in template_dirs:
            try:
                name = safe_join(template_dir, template_name)
            except SuspiciousFileOperation:
                # The joined path was located outside of this template_dir
                # (it might be inside another one, so this isn't fatal).
                continue

            yield Origin(
                name=name,
                template_name=template_name,
                loader=self,
            ) 
開發者ID:tethysplatform,項目名稱:tethys,代碼行數:23,代碼來源:template_loaders.py

示例6: get_template_sources

# 需要導入模塊: from django import template [as 別名]
# 或者: from django.template import Origin [as 別名]
def get_template_sources(self, template_name):
        yield Origin(
            name=template_name,
            template_name=template_name,
            loader=self,
        ) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:8,代碼來源:locmem.py

示例7: find_template

# 需要導入模塊: from django import template [as 別名]
# 或者: from django.template import Origin [as 別名]
def find_template(self, name, dirs=None):
        """
        RemovedInDjango20Warning: An internal method to lookup the template
        name in all the configured loaders.
        """
        key = self.cache_key(name, dirs)
        try:
            result = self.find_template_cache[key]
        except KeyError:
            result = None
            for loader in self.loaders:
                try:
                    template, display_name = loader(name, dirs)
                except TemplateDoesNotExist:
                    pass
                else:
                    origin = Origin(
                        name=display_name,
                        template_name=name,
                        loader=loader,
                    )
                    result = template, origin
                    break
        self.find_template_cache[key] = result
        if result:
            return result
        else:
            self.template_cache[key] = TemplateDoesNotExist
            raise TemplateDoesNotExist(name) 
開發者ID:Yeah-Kun,項目名稱:python,代碼行數:31,代碼來源:cached.py


注:本文中的django.template.Origin方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。