Skip to content

Latest commit

 

History

History
49 lines (32 loc) · 1.46 KB

signals.rst

File metadata and controls

49 lines (32 loc) · 1.46 KB

Signals (event hooking)

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/

Installing Blinker -- REQUIRED!

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/

Subscribing to Signals

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')
For all Flask-User event signals:
- sender points to the app, and
- user points to the user that is associated with this event.

See Subscribing to signals

Troubleshooting

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).