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


Python session.pop方法代码示例

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


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

示例1: cancel_github_authorization

# 需要导入模块: from flask import session [as 别名]
# 或者: from flask.session import pop [as 别名]
def cancel_github_authorization(dev_key):
    print('cancel github authorization')
    developer = Developer.query.filter_by(dev_key=dev_key).first()
    if developer is None:
        abort(400)
    authorization = Authorization.query.filter_by(developer=developer, type='github').first()
    if authorization:
        try:
            db.session.delete(authorization)
            db.session.commit()
        except:
            db.session.rollback()
            abort(500)
    session.pop('user', None)
    session.pop('github_token', None)
    return jsonify({}), 200 
开发者ID:jpush,项目名称:jbox,代码行数:18,代码来源:github.py

示例2: google_login

# 需要导入模块: from flask import session [as 别名]
# 或者: from flask.session import pop [as 别名]
def google_login():
    # to avoid flask-login displaying the login error message
    session.pop("_flashes", None)

    next_url = request.args.get("next")

    # Google does not allow to append param to redirect_url
    # we need to pass the next url by session
    if next_url:
        session["google_next_url"] = next_url

    google = OAuth2Session(GOOGLE_CLIENT_ID, scope=_scope, redirect_uri=_redirect_uri)
    authorization_url, state = google.authorization_url(_authorization_base_url)

    # State is used to prevent CSRF, keep this for later.
    session["oauth_state"] = state
    return redirect(authorization_url) 
开发者ID:simple-login,项目名称:app,代码行数:19,代码来源:google.py

示例3: facebook_login

# 需要导入模块: from flask import session [as 别名]
# 或者: from flask.session import pop [as 别名]
def facebook_login():
    # to avoid flask-login displaying the login error message
    session.pop("_flashes", None)

    next_url = request.args.get("next")

    # Facebook does not allow to append param to redirect_uri
    # we need to pass the next url by session
    if next_url:
        session["facebook_next_url"] = next_url

    facebook = OAuth2Session(
        FACEBOOK_CLIENT_ID, scope=_scope, redirect_uri=_redirect_uri
    )
    facebook = facebook_compliance_fix(facebook)
    authorization_url, state = facebook.authorization_url(_authorization_base_url)

    # State is used to prevent CSRF, keep this for later.
    session["oauth_state"] = state
    return redirect(authorization_url) 
开发者ID:simple-login,项目名称:app,代码行数:22,代码来源:facebook.py

示例4: consent

# 需要导入模块: from flask import session [as 别名]
# 或者: from flask.session import pop [as 别名]
def consent():
    # redirect to next url when current user has already consented
    if current_user.has_consented:
        return redirect(session.pop("next_url", default_url()))
    form = ConsentForm()

    if form.validate_on_submit():
        current_user.consented_at = datetime.utcnow()
        current_user.profile_consent = True
        current_user.org_consent = True
        current_user.cookies_consent = True
        current_user.age_consent = True
        current_user.save()
        next_url = session.pop("next_url", default_url())
        return redirect(next_url)

    return {"form": form} 
开发者ID:jazzband-roadies,项目名称:website,代码行数:19,代码来源:views.py

示例5: do_create

# 需要导入模块: from flask import session [as 别名]
# 或者: from flask.session import pop [as 别名]
def do_create():

    session.pop('username', None)

    if request.method == 'POST':

        username = request.form.get('username')
        password = request.form.get('password')
        email = request.form.get('password')

        session['username'] = libuser.login(username, password)

        if session['username']:
            return redirect('/')

    return render_template('user.create.html') 
开发者ID:fportantier,项目名称:vulpy,代码行数:18,代码来源:mod_user.py

示例6: do_create

# 需要导入模块: from flask import session [as 别名]
# 或者: from flask.session import pop [as 别名]
def do_create():

    session.pop('username', None)

    if request.method == 'POST':

        username = request.form.get('username')
        password = request.form.get('password')
        #email = request.form.get('password')
        if not username or not password:
            flash("Please, complete username and password")
            return render_template('user.create.html')

        libuser.create(username, password)
        flash("User created. Please login.")
        return redirect('/user/login')

        #session['username'] = libuser.login(username, password)

        #if session['username']:
        #    return redirect('/')

    return render_template('user.create.html') 
开发者ID:fportantier,项目名称:vulpy,代码行数:25,代码来源:mod_user.py

示例7: authorize_view

# 需要导入模块: from flask import session [as 别名]
# 或者: from flask.session import pop [as 别名]
def authorize_view(self):
        """Flask view that starts the authorization flow.

        Starts flow by redirecting the user to the OAuth2 provider.
        """
        args = request.args.to_dict()

        # Scopes will be passed as mutliple args, and to_dict() will only
        # return one. So, we use getlist() to get all of the scopes.
        args['scopes'] = request.args.getlist('scopes')

        return_url = args.pop('return_url', None)
        if return_url is None:
            return_url = request.referrer or '/'

        flow = self._make_flow(return_url=return_url, **args)
        auth_url = flow.step1_get_authorize_url()

        return redirect(auth_url) 
开发者ID:Deltares,项目名称:aqua-monitor,代码行数:21,代码来源:flask_util.py

示例8: dropsession

# 需要导入模块: from flask import session [as 别名]
# 或者: from flask.session import pop [as 别名]
def dropsession():

        try:

            if session.get('user'):
                username = session.get('user')
                session.pop('user', None)
                session.pop('is_admin', False)
                Message = f"Session for user: {username} terminated."
                app.logger.warning(Message)
                Create_Event(Message)

            return render_template('index.html', loggedout=True)

        except Exception as e:
            app.logger.error(e)
            return redirect(url_for('index')) 
开发者ID:matamorphosis,项目名称:Scrummage,代码行数:19,代码来源:Scrummage.py

示例9: reset_settings

# 需要导入模块: from flask import session [as 别名]
# 或者: from flask.session import pop [as 别名]
def reset_settings():
    session.pop('space_id', None)
    session.pop('delivery_token', None)
    session.pop('preview_token', None)
    session.pop('editorial_features', None)

    space = contentful().space(api_id())

    return render_with_globals(
        'settings',
        title=translate('settingsLabel', locale().code),
        errors={},
        has_errors=False,
        success=False,
        space=space,
        host=request.url_root
    ) 
开发者ID:contentful,项目名称:the-example-app.py,代码行数:19,代码来源:settings.py

示例10: with_logger

# 需要导入模块: from flask import session [as 别名]
# 或者: from flask.session import pop [as 别名]
def with_logger(kwarg='logger', stream_dest_kwarg='stream', replace=True):
  ''' Decorator that creates a new :class:`logging.Logger` object
  additionally to or in-place for the *stream* parameter passed to
  the wrapped function. This is usually used in combination with
  the :func:`with_io_response` decorator.

  Note that exceptions with this decorator will be logged and the
  returned status code will be 500 Internal Server Error. '''

  def decorator(func):
    @functools.wraps(func)
    def wrapper(*args, **kwargs):
      if replace:
        stream = kwargs.pop(stream_dest_kwarg)
      else:
        stream = kwargs[stream_dest_kwarg]
      kwargs[kwarg] = logger = create_logger(stream)
      try:
        return func(*args, **kwargs)
      except BaseException as exc:
        logger.exception(exc)
        return 500
    return wrapper

  return decorator 
开发者ID:NiklasRosenstein,项目名称:flux-ci,代码行数:27,代码来源:utils.py

示例11: logout

# 需要导入模块: from flask import session [as 别名]
# 或者: from flask.session import pop [as 别名]
def logout():
    session.pop('logged_in', None)
    session.pop('active_user', None)
    flask.flash('You were logged out!')
    return redirect(url_for("index")) 
开发者ID:llvm,项目名称:llvm-zorg,代码行数:7,代码来源:views.py

示例12: logout_oauth_user

# 需要导入模块: from flask import session [as 别名]
# 或者: from flask.session import pop [as 别名]
def logout_oauth_user():
    for oauth_key in oauth_check.keys():
        if str(oauth_key) + '_oauth_user_id' in session:
            session.pop(str(oauth_key) + '_oauth_user_id') 
开发者ID:janeczku,项目名称:calibre-web,代码行数:6,代码来源:oauth_bb.py

示例13: logout

# 需要导入模块: from flask import session [as 别名]
# 或者: from flask.session import pop [as 别名]
def logout():
    session.pop('qq_token', None)
    return redirect(url_for('main.index')) 
开发者ID:jpush,项目名称:jbox,代码行数:5,代码来源:views.py

示例14: revoke

# 需要导入模块: from flask import session [as 别名]
# 或者: from flask.session import pop [as 别名]
def revoke(self):
        """This method clears current discord token, state and all session data from flask
        `session <http://flask.pocoo.org/docs/1.0/api/#flask.session>`_. Which means user will have
        to go through discord authorization token grant flow again. Also tries to remove the user from internal
        cache if they exist.

        """

        self.users_cache.pop(self.user_id, None)

        for session_key in self.SESSION_KEYS:
            try:
                session.pop(session_key)
            except KeyError:
                pass 
开发者ID:thec0sm0s,项目名称:Flask-Discord,代码行数:17,代码来源:client.py

示例15: preprocess_request

# 需要导入模块: from flask import session [as 别名]
# 或者: from flask.session import pop [as 别名]
def preprocess_request():
  if request.endpoint in {'redirect_view', 'proxy_view', 'pending_view', 'leaderboard_view', 'user_leaderboard_view'}:
    if request.view_args.get('object_key'):
      session['object_key'] = request.view_args.get('object_key')
    if session.get('verified') != True:
      session['next'] = request.url
      return redirect(url_for('login_view'))
    if session.get('next'):
      return redirect(session.pop('next'))
    if not s3:
      flash('Your S3 keys are invalid!', 'danger')
      return 'Your S3 keys are invalid!' 
开发者ID:yasyf,项目名称:shamer,代码行数:14,代码来源:app.py


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