Adjust state

This commit is contained in:
Matt Wright
2012-07-16 19:40:34 -04:00
parent e23581e260
commit 1c606a242a
2 changed files with 8 additions and 3 deletions
+2 -2
View File
@@ -22,7 +22,7 @@ from flask.ext.security.decorators import http_auth_required, \
def create_roles():
for role in ('admin', 'editor', 'author'):
current_app.extensions['security'].datastore.create_role(name=role)
current_app.security.datastore.create_role(name=role)
def create_users():
@@ -31,7 +31,7 @@ def create_users():
('dave@lp.com', 'password', ['admin', 'editor'], True),
('jill@lp.com', 'password', ['author'], True),
('tiya@lp.com', 'password', [], False)):
current_app.extensions['security'].datastore.create_user(
current_app.security.datastore.create_user(
email=u[0], password=u[1], roles=u[2], active=u[3])
+6 -1
View File
@@ -208,7 +208,7 @@ class Security(object):
"""
def __init__(self, app=None, datastore=None, **kwargs):
if app is not None and datastore is not None:
self.init_app(app, datastore, **kwargs)
self._state = self.init_app(app, datastore, **kwargs)
def init_app(self, app, datastore, register_blueprint=True):
"""Initializes the Flask-Security extension for the specified
@@ -253,6 +253,11 @@ class Security(object):
app.extensions['security'] = state
return state
def __getattr__(self, name):
return getattr(self._state, name, None)
class AuthenticationProvider(object):
"""The default authentication provider implementation."""