Flask Applications that want to be kept informed about certain actions that took place in the underlying Flask-User extensions can do so by subscribing 'signals' to receive event notification.
Flask-User defines the following signals:
See the http://flask.pocoo.org/docs/signals/
NB: Flask-User relies on Flask signals, which relies on the 'blinker' package. Event notification WILL NOT WORK without first installing the 'blinker' package.
pip install blinker
See http://pythonhosted.org/blinker/
AFTER BLINKER HAS BEEN INSTALLED, An application can receive event notifications
by using the event signal's connect_via()
decorator:
from flask_user import user_logged_in @user_logged_in.connect_via(app) def _after_login_hook(sender, user, **extra): sender.logger.info('user logged in')
sender
points to the app, anduser
points to the user that is associated with this event.If the code looks right, but the tracking functions are not called, make sure to check
to see if the 'blinker' package has been installed (analyze the output of pip freeze
).