From 703487e608ee0a5daef8793dbbe242868bac57f3 Mon Sep 17 00:00:00 2001 From: Matt Wright Date: Tue, 10 Jul 2012 17:29:43 -0400 Subject: [PATCH] Move things around for aesthetic reasons --- flask_security/core.py | 92 +++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/flask_security/core.py b/flask_security/core.py index 925e8c3..603a91a 100644 --- a/flask_security/core.py +++ b/flask_security/core.py @@ -56,52 +56,6 @@ _default_config = { } -class RoleMixin(object): - """Mixin for `Role` model definitions""" - def __eq__(self, other): - return self.name == other or self.name == getattr(other, 'name', None) - - def __ne__(self, other): - return self.name != other and self.name != getattr(other, 'name', None) - - def __str__(self): - return '' % self.name - - -class UserMixin(BaseUserMixin): - """Mixin for `User` model definitions""" - - def is_active(self): - """Returns `True` if the user is active.""" - return self.active - - def get_auth_token(self): - """Returns the user's authentication token.""" - self.remember_token - - def has_role(self, role): - """Returns `True` if the user identifies with the specified role. - - :param role: A role name or `Role` instance""" - return role in self.roles - - def __str__(self): - ctx = (str(self.id), self.email) - return '' % ctx - - -class AnonymousUser(AnonymousUserBase): - """AnonymousUser definition""" - - def __init__(self): - super(AnonymousUser, self).__init__() - self.roles = ImmutableList() - - def has_role(self, *args): - """Returns `False`""" - return False - - def _user_loader(user_id): try: return current_app.security.datastore.with_id(user_id) @@ -185,6 +139,52 @@ def _create_blueprint(app): return bp +class RoleMixin(object): + """Mixin for `Role` model definitions""" + def __eq__(self, other): + return self.name == other or self.name == getattr(other, 'name', None) + + def __ne__(self, other): + return self.name != other and self.name != getattr(other, 'name', None) + + def __str__(self): + return '' % self.name + + +class UserMixin(BaseUserMixin): + """Mixin for `User` model definitions""" + + def is_active(self): + """Returns `True` if the user is active.""" + return self.active + + def get_auth_token(self): + """Returns the user's authentication token.""" + self.remember_token + + def has_role(self, role): + """Returns `True` if the user identifies with the specified role. + + :param role: A role name or `Role` instance""" + return role in self.roles + + def __str__(self): + ctx = (str(self.id), self.email) + return '' % ctx + + +class AnonymousUser(AnonymousUserBase): + """AnonymousUser definition""" + + def __init__(self): + super(AnonymousUser, self).__init__() + self.roles = ImmutableList() + + def has_role(self, *args): + """Returns `False`""" + return False + + class Security(object): """The :class:`Security` class initializes the Flask-Security extension.