當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。