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


Python flask.get_flashed_messages方法代码示例

本文整理汇总了Python中flask.get_flashed_messages方法的典型用法代码示例。如果您正苦于以下问题:Python flask.get_flashed_messages方法的具体用法?Python flask.get_flashed_messages怎么用?Python flask.get_flashed_messages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flask的用法示例。


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

示例1: render

# 需要导入模块: import flask [as 别名]
# 或者: from flask import get_flashed_messages [as 别名]
def render(self):
        messages = get_flashed_messages(with_categories=True)
        if messages:
            html = '<div class="notifications">\n'
            for category, message in messages:
                html += '<p class="%s">%s</p>\n' % (category, message)
            html += '</div>'
            return html
        return '' 
开发者ID:whiteclover,项目名称:white,代码行数:11,代码来源:flash.py

示例2: validation_error

# 需要导入模块: import flask [as 别名]
# 或者: from flask import get_flashed_messages [as 别名]
def validation_error(path=None):
    if choose_media_type(acceptable_media_types(request), [html]):
        if path:
            return flask_redirect(path)
        else:
            return flask_redirect(request.referrer)
    else:
        return render_json({'errors': get_flashed_messages()}) 
开发者ID:certsocietegenerale,项目名称:fame,代码行数:10,代码来源:negotiation.py

示例3: jsonify

# 需要导入模块: import flask [as 别名]
# 或者: from flask import get_flashed_messages [as 别名]
def jsonify(*args, **kwargs):
    messages = [{'message': m, 'category':c} for c, m in
            flask.get_flashed_messages(with_categories=True)]
    return flask.jsonify(*args, flashed_messages=messages, **kwargs) 
开发者ID:paxswill,项目名称:evesrp,代码行数:6,代码来源:jsonify.py

示例4: post

# 需要导入模块: import flask [as 别名]
# 或者: from flask import get_flashed_messages [as 别名]
def post(self):
        """Propagate a message to the next screen (or whatever reads the session)"""
        def translate(level):
            levels = ['danger', 'warning', 'info', 'success']
            convert = {
                '0': 'success',
                '1': 'warning',
                '2': 'error',
                '3': 'info'
            }
            if not level:
                return 'danger'
            # return the converted value or the one we already had
            new = convert.get(level, level)
            # if the level is not handled, assume 'danger'
            if new not in levels:
                return 'danger'
            return new

        # retrieve last flashed messages so we don't loose anything
        for level, message in get_flashed_messages(with_categories=True):
            flash(message, level)

        args = self.parser.parse_args()
        message = args['message']
        level = translate(args['level'])
        flash(message, level)
        return {'message': message, 'level': level}, 201 
开发者ID:ziirish,项目名称:burp-ui,代码行数:30,代码来源:misc.py

示例5: get_grouped_flashed_messages

# 需要导入模块: import flask [as 别名]
# 或者: from flask import get_flashed_messages [as 别名]
def get_grouped_flashed_messages():
    """
    Gets the current set of flashed messages and returns them
    grouped by the appropriate Bootstrap contextual alert class.

    Returns:
        A dictionary of all messages, keyed by the appropriate
        Bootstrap contextual alert class.
    """
    # This will contain the lists of flashed messages,
    # keyed by the appropriate contextual Bootstrap class.
    grouped_messages = {
    }

    # Go through the messages
    for category, message in get_flashed_messages(with_categories=True):
        # Try to figure out the contextual class, defaulting to 'alert-info'.
        alert_class = flash_message_classes.get(category, 'alert-info')

        # Set up a list value for the relevant list class if not found.
        if alert_class not in grouped_messages:
            grouped_messages[alert_class] = list()

        grouped_messages[alert_class].append(message)

    return grouped_messages 
开发者ID:radremedy,项目名称:radremedy,代码行数:28,代码来源:remedy_utils.py

示例6: test_flashes

# 需要导入模块: import flask [as 别名]
# 或者: from flask import get_flashed_messages [as 别名]
def test_flashes(self):
        app = flask.Flask(__name__)
        app.secret_key = 'testkey'

        with app.test_request_context():
            self.assert_false(flask.session.modified)
            flask.flash('Zap')
            flask.session.modified = False
            flask.flash('Zip')
            self.assert_true(flask.session.modified)
            self.assert_equal(list(flask.get_flashed_messages()), ['Zap', 'Zip']) 
开发者ID:chalasr,项目名称:Flask-P2P,代码行数:13,代码来源:basic.py

示例7: before_request

# 需要导入模块: import flask [as 别名]
# 或者: from flask import get_flashed_messages [as 别名]
def before_request():
    g.alerts = get_flashed_messages()
    g.login_form = LoginForm()
    g.now = datetime.now() 
开发者ID:c3bottles,项目名称:c3bottles,代码行数:6,代码来源:__init__.py

示例8: make_cache_key

# 需要导入模块: import flask [as 别名]
# 或者: from flask import get_flashed_messages [as 别名]
def make_cache_key(*args, **kwargs):
    path = request.path
    args = str(hash(frozenset(request.args.items())))
    messages = str(hash(frozenset(get_flashed_messages())))
    if current_user.is_authenticated:
        roles = str(current_user.roles)
    else:
        roles = ""
    return (path + args + roles + session.get('locale', '') + messages).encode('utf-8') 
开发者ID:PacktPublishing,项目名称:Mastering-Flask-Web-Development-Second-Edition,代码行数:11,代码来源:controllers.py

示例9: __call__

# 需要导入模块: import flask [as 别名]
# 或者: from flask import get_flashed_messages [as 别名]
def __call__(self):

        messages = ''
        for (cate, msg) in get_flashed_messages(with_categories=True):
            if cate == 'message':
                cate = 'warning'
            messages += _TEMPLATE.format(message=msg, category=cate)

        return Markup(messages) 
开发者ID:fushall,项目名称:myblog,代码行数:11,代码来源:__init__.py

示例10: get_infos

# 需要导入模块: import flask [as 别名]
# 或者: from flask import get_flashed_messages [as 别名]
def get_infos():
    return get_flashed_messages(category_filter=request.endpoint + ".infos") 
开发者ID:CTFd,项目名称:CTFd,代码行数:4,代码来源:__init__.py

示例11: get_errors

# 需要导入模块: import flask [as 别名]
# 或者: from flask import get_flashed_messages [as 别名]
def get_errors():
    return get_flashed_messages(category_filter=request.endpoint + ".errors") 
开发者ID:CTFd,项目名称:CTFd,代码行数:4,代码来源:__init__.py

示例12: common_bootstrap_payload

# 需要导入模块: import flask [as 别名]
# 或者: from flask import get_flashed_messages [as 别名]
def common_bootstrap_payload() -> Dict[str, Any]:
    """Common data always sent to the client"""
    messages = get_flashed_messages(with_categories=True)
    locale = str(get_locale())

    return {
        "flash_messages": messages,
        "conf": {k: conf.get(k) for k in FRONTEND_CONF_KEYS},
        "locale": locale,
        "language_pack": get_language_pack(locale),
        "feature_flags": get_feature_flags(),
        "menu_data": menu_data(),
    } 
开发者ID:apache,项目名称:incubator-superset,代码行数:15,代码来源:base.py


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