flasky: TypeError: 'bool' object is not callable

I followed your book to learn flask, it works very well until I used current_user , I got

AttributeError: 'bool' object has no attribute '__call__'

this kind of error. I thought maybe there’re some mistakes in my code, so I download your code from github, and checkout to branch 8c, but same thing happend, check traceback message below:

root@fb-kali:/opt/flasky# python manage.py runserver --port 8888 --host 0.0.0.0 --debug
 * Running on http://0.0.0.0:8888/
 * Restarting with reloader
127.0.0.1 - - [16/Sep/2015 16:29:42] "GET / HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/usr/share/pyshared/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/share/pyshared/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/usr/share/pyshared/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/share/pyshared/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/share/pyshared/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/share/pyshared/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/share/pyshared/flask/app.py", line 1473, in full_dispatch_request
    rv = self.preprocess_request()
  File "/usr/share/pyshared/flask/app.py", line 1666, in preprocess_request
    rv = func()
  File "/opt/flasky/app/auth/views.py", line 14, in before_request
    if current_user.is_authenticated() \
TypeError: 'bool' object is not callable

Here is the version of some related package I’m using:

Python 2.7.9
Flask==0.10.1
Flask-Bootstrap==3.3.5.6
Flask-Login==0.3.0
Flask-Mail==0.9.1
Flask-Migrate==1.5.1
Flask-Moment==0.5.1
Flask-SQLAlchemy==2.0
Flask-Script==2.0.5
Flask-WTF==0.12
Jinja2==2.7.3
WTForms==2.0.2
Werkzeug==0.9.6

Thank you so much if you can help me solve this problem.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

I’ve already solved this problem. Since 0.3.0, Flask-Login has set is_active is_authenticated is_anonymous to property in UserMixin, so we should use current_user.is_authenticated instead of current_user.is_authenticated().

This is a silly change, from getter function to property – broke site instantly for no good reason.