Python flask.session 模块,modified() 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用flask.session.modified()

项目:hashtagtodo-open    作者:slackpad    | 项目源码 | 文件源码
def login(provider):
    if request.method == 'POST':
        session.permanent = 'remember' in request.form
        session.modified = True

    response = make_response()
    result = AUTHOMATIC.login(WerkzeugAdapter(request, response), provider)
    if result:
        if result.user:
            result.user.update()
            credentials = result.user.credentials.serialize()
            user = User.create_or_update(provider,
                                         result.user.id,
                                         result.user.email,
                                         result.user.first_name,
                                         result.user.last_name,
                                         credentials)
            session['user'] = user.key.urlsafe()

            # If they are on the freemium list hook them up.
            if (not user.is_premium) and (Freemium.get_by_email(result.user.email) is not None):
                user.is_premium = True
                user.put()
                flash('You\'ve been upgraded to a free premium account for one year!')

            return redirect('/todos')

        return render_template('login.html', result=result)

    return response
项目:neogoso    作者:neogoso    | 项目源码 | 文件源码
def session_reset():
    session.modified = True
    session.permanent = True
    app.permanent_session_lifetime = timedelta(minutes=30)
项目:farm-to-front-door    作者:Gerdie    | 项目源码 | 文件源码
def get_cart_total(cart):
    """Calculate total price of cart"""

    session["cart_total"] = 0.00

    for item in cart:
        session["cart_total"] += item.price * session['cart'][item.product_id]
    if session.get('delivery') and session['delivery']['delivery'] == unicode('delivery'):
        session["cart_total"] += 5.00

    session.modified = True
项目:synergy_website    作者:alfredojf    | 项目源码 | 文件源码
def make_session_permanent():
    session.permanent = True
    app.permanent_session_lifetime = timedelta(minutes=45)
    session.modified = True
项目:python-flask-security    作者:weinbergdavid    | 项目源码 | 文件源码
def session_identity_saver(identity):
    session['identity.id'] = identity.id
    session['identity.auth_type'] = identity.auth_type
    session.modified = True
项目:paste    作者:NextFloor    | 项目源码 | 文件源码
def view(slug):
    paste = Paste.get_or_404(slug)
    if paste.password:
        form = PasswordForm()
        if form.validate_on_submit():
            if not paste.verify_password(form.password.data):
                flash('????? ???? ????.', 'error')
                return render_template('password.html', form=form)
        else:
            form.flash_errors()
            return render_template('password.html', form=form)

    viewed = session.setdefault('viewed', [])
    if paste.slug not in viewed:
        viewed.append(paste.slug)
        session.permanent = True
        session.modified = True
        paste.view_count += 1
        db.session.add(paste)
        db.session.commit()

    lexer = get_lexer_by_name(paste.lexer)
    formatter = HtmlFormatter(
        linenos=True,
        linespans='line',
        lineanchors='line',
        anchorlinenos=True,
    )

    return render_template(
        'view.html',
        styles=formatter.get_style_defs(),
        highlighted_source=highlight(paste.source, lexer, formatter),
        lexer=lexer,
        paste=paste,
    )