Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Where would I put signals? #31

Open
dukedougal opened this issue Aug 1, 2014 · 2 comments
Open

Where would I put signals? #31

dukedougal opened this issue Aug 1, 2014 · 2 comments

Comments

@dukedougal
Copy link

HI Matt

I'm pretty stuck working out how to implement a signal from flask-security that tells me when a user has registered and when a user has logged in.

Are you able to suggest how to do this and where you would put such functionality in Overholt?

thanks

@mattupstate
Copy link
Owner

Signals could be registered wherever you like. Perhaps create a signals.py module and import signals from various places and place your handler functions there as well.

@mattupstate
Copy link
Owner

@dukedougal pseudo code, but this hopefully illustrates:

# factory.py
from flask import Flask
from .signals import init_signals

def create_app(package_name):
    app = Flask(package_name)
    init_signals(app)
    return app


# signals.py
from flask_security.signals import user_registered

def on_user_registered(sender, **kwargs):
    pass

def init_signals(app):
    user_registered.connect_via(app)(on_user_registered)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants