Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/359.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Flask登录名`user\u callback`未设置,`user\u loader`似乎被调用了两次_Python_Flask_Flask Login - Fatal编程技术网

Python Flask登录名`user\u callback`未设置,`user\u loader`似乎被调用了两次

Python Flask登录名`user\u callback`未设置,`user\u loader`似乎被调用了两次,python,flask,flask-login,Python,Flask,Flask Login,我正在使用flask构建一个相当简单的python应用程序。我在登录时遇到麻烦了。直到今天早上我升级了我的项目依赖项之前,一切似乎都在运行,现在我不知道会发生什么 我得到的错误是TypeError:“NoneType”对象不可调用。以下是完整的堆栈跟踪: Traceback (most recent call last): File "C:\Users\acrowder\venv\lib\site-packages\flask\app.py", line 1836, in __call__ re

我正在使用flask构建一个相当简单的python应用程序。我在登录时遇到麻烦了。直到今天早上我升级了我的项目依赖项之前,一切似乎都在运行,现在我不知道会发生什么

我得到的错误是
TypeError:“NoneType”对象不可调用
。以下是完整的堆栈跟踪:

Traceback (most recent call last):
File "C:\Users\acrowder\venv\lib\site-packages\flask\app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Users\acrowder\venv\lib\site-packages\flask\app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "C:\Users\acrowder\venv\lib\site-packages\flask\app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\acrowder\venv\lib\site-packages\flask\_compat.py", line 33, in reraise
raise value
File "C:\Users\acrowder\venv\lib\site-packages\flask\app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\acrowder\venv\lib\site-packages\flask\app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\acrowder\venv\lib\site-packages\flask\app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\acrowder\venv\lib\site-packages\flask\_compat.py", line 33, in reraise
raise value
File "C:\Users\acrowder\venv\lib\site-packages\flask\app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\acrowder\venv\lib\site-packages\flask\app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Code\crowdcontrol\app\site\views.py", line 52, in page
return render_template(template_path, page=the_page, menu=menu)
File "C:\Users\acrowder\venv\lib\site-packages\flask\templating.py", line 126, in render_template
ctx.app.update_template_context(context)
File "C:\Users\acrowder\venv\lib\site-packages\flask\app.py", line 716, in update_template_context
context.update(func())
File "C:\Users\acrowder\venv\lib\site-packages\flask_login.py", line 825, in _user_context_processor
return dict(current_user=_get_user())
File "C:\Users\acrowder\venv\lib\site-packages\flask_login.py", line 794, in _get_user
current_app.login_manager._load_user()
File "C:\Users\acrowder\venv\lib\site-packages\flask_login.py", line 363, in _load_user
return self.reload_user()
File "C:\Users\acrowder\venv\lib\site-packages\flask_login.py", line 325, in reload_user
user = self.user_callback(user_id)
TypeError: 'NoneType' object is not callable
这是我的应用程序的init.py:

import os
from flask import Flask
from flask.ext.bootstrap import Bootstrap
from flask.ext.mail import Mail
from flask.ext.moment import Moment
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.login import LoginManager
from config import config
from app.jinja_filters import format_datetime

bootstrap = Bootstrap()
mail = Mail()
moment = Moment()
db = SQLAlchemy()

login_manager = LoginManager()

def create_app(config_name):
    the_app = Flask(__name__)
    the_app.config.from_object(config[config_name])
    config[config_name].init_app(the_app)

    bootstrap.init_app(the_app)
    mail.init_app(the_app)
    moment.init_app(the_app)
    db.init_app(the_app)

    # Let's set up our login handlers
    import app.login_handlers
    login_manager.session_protection = 'strong'
    login_manager.login_view = 'auth.login'
    login_manager.init_app(the_app)

    the_app.jinja_env.filters['datetime'] = format_datetime

    from app.site import site as site_blueprint
    the_app.register_blueprint(site_blueprint)

    from app.blog import blog as blog_blueprint
    the_app.register_blueprint(blog_blueprint)

    from app.admin import admin as admin_blueprint
    the_app.register_blueprint(admin_blueprint, url_prefix="/admin")

    from app.auth import auth as auth_blueprint
    the_app.register_blueprint(auth_blueprint, url_prefix="/auth")

    return the_app


app = create_app(os.getenv('FLASK_CONFIG') or 'default')

if __name__ == "__main__":
    app.run()
这是我的login_handlers.py文件:

from app import login_manager
from app.models import User


@login_manager.user_loader
def load_user(user_id):
    return User.query.get(int(user_id))
我在第216行的flask_login.py中输入了断点,似乎调用了两次。但我不知道从哪里开始