Created
September 11, 2015 20:30
-
-
Save rdegges/59da2603d332252745f0 to your computer and use it in GitHub Desktop.
Stormpath Python signal example.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pydispatch import dispatcher | |
from stormpath.client import Client | |
from stormpath.resources.base import SIGNAL_RESOURCE_CREATED | |
def resource_created(signal, sender, data, params): | |
"""Prints off some signal data when a resource is created.""" | |
print 'signal:', signal | |
print 'sender:', sender | |
print 'data:', data | |
print 'params:', params | |
client = Client(id='xxx', secret='yyy') | |
application = client.applications.search({'name': 'demoapp'})[0] | |
# Listen for all object creations. | |
# You can also bind to SIGNAL_RESOURCE_UPDATED / SIGNAL_RESOURCE_DELETED | |
dispatcher.connect(resource_created, signal=SIGNAL_RESOURCE_CREATED) | |
# When this account is created, the signal handler will be ran. | |
application.accounts.create({ | |
'given_name': 'Randall', | |
'surname': 'Degges', | |
'email': '[email protected]', | |
'password': 'woot1LOVEc00kies=)' | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment