themes.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:mos-horizon 作者: Mirantis 项目源码 文件源码
def get_template_sources(self, template_name):

        # If the cookie doesn't exist, set it to the default theme
        default_theme = get_default_theme()
        theme = getattr(_local, 'theme', default_theme)
        this_theme = find_theme(theme)

        # If the theme is not valid, check the default theme ...
        if not this_theme:
            this_theme = find_theme(get_default_theme())

            # If the theme is still not valid, then move along ...
            # these aren't the templates you are looking for
            if not this_theme:
                pass

        try:
            if not template_name.startswith('/'):
                try:
                    yield safe_join(
                        'openstack_dashboard',
                        this_theme[2],
                        'templates',
                        template_name
                    )
                except SuspiciousFileOperation:
                    yield os.path.join(
                        this_theme[2], 'templates', template_name
                    )

        except UnicodeDecodeError:
            # The template dir name wasn't valid UTF-8.
            raise
        except ValueError:
            # The joined path was located outside of template_dir.
            pass
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号