python - Flask-Login `user_callback` not being set, `user_loader` seems to be called twice -
i'm building simple python application using flask. i'm running trouble flask-login. seemed working until upgraded projects dependencies morning , can't figure out going on.
the error i'm getting typeerror: 'nonetype' object not callable
. here full stack trace:
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 not callable
here's init.py app:
import os flask import flask flask.ext.bootstrap import bootstrap flask.ext.mail import mail flask.ext.moment import moment flask.ext.sqlalchemy import sqlalchemy flask.ext.login import loginmanager config import config 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 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 app.site import site site_blueprint the_app.register_blueprint(site_blueprint) app.blog import blog blog_blueprint the_app.register_blueprint(blog_blueprint) app.admin import admin admin_blueprint the_app.register_blueprint(admin_blueprint, url_prefix="/admin") app.auth import auth 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()
and here's login_handlers.py file:
from app import login_manager app.models import user @login_manager.user_loader def load_user(user_id): return user.query.get(int(user_id))
i've put in breakpoint in flask_login.py on line 216, , seems called twice. can't figure out where.
Comments
Post a Comment