コード例 #1
0
ファイル: __init__.py プロジェクト: pombredanne/moin2
def get_current_theme():
    # this might be called at a time when flaskg.user is not setup yet:
    u = getattr(flaskg, 'user', None)
    if u and u.theme_name is not None:
        theme_name = u.theme_name
    else:
        theme_name = app.cfg.theme_default
    try:
        return get_theme(theme_name)
    except KeyError:
        logging.warning("Theme {0} was not found; using default of {1} instead.".format(theme_name, app.cfg.theme_default))
        theme_name = app.cfg.theme_default
        return get_theme(theme_name)
コード例 #2
0
def get_current_theme():
    # this might be called at a time when flaskg.user is not setup yet:
    u = getattr(flaskg, 'user', None)
    if u and u.theme_name is not None:
        theme_name = u.theme_name
    else:
        theme_name = app.cfg.theme_default
    return get_theme(theme_name)
コード例 #3
0
ファイル: test-themes.py プロジェクト: guotie/flask-themes
 def test_get_helpers(self):
     app = Flask(__name__)
     app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')]
     setup_themes(app, app_identifier='testing')
     
     with app.test_request_context('/'):
         cool = app.theme_manager.themes['cool']
         plain = app.theme_manager.themes['plain']
         assert get_theme('cool') is cool
         assert get_theme('plain') is plain
         tl = get_themes_list()
         assert tl[0] is cool
         assert tl[1] is plain
         try:
             get_theme('notthis')
         except KeyError:
             pass
         else:
             raise AssertionError("Getting a nonexistent theme should "
                                  "raised KeyError")
コード例 #4
0
def get_my_theme():
    g.theme = get_theme(app.config['THEME'])
コード例 #5
0
ファイル: themes.py プロジェクト: nickvlku/hootenflaten
def get_current_theme():
    theme = current_app.config.get("THEME", "plain")
    return get_theme(theme)