Is it legal to make an import like this:
from webapp2_extras.appengine.auth.models import User as webapp2.User
I'd like to refer to the object as webapp2.User even though it technically is not. This is because there are other object named User so I'd proabbly name Users with this model something like webapp2_user as distinct from fbuser (facebook user who comes via "login with facebook") and google users. It seems a good class since it admits connecting your google or facebook other account with this model:
class User(object):
def get_id(self):
"""Returns this user's unique ID, which can be an integer or string."""
@classmethod
def get_by_auth_token(cls, user_id, token):
"""Returns a user object based on a user ID and token.
:param user_id:
The user_id of the requesting user.
:param token:
The token string to be verified.
:returns:
A tuple ``(User, timestamp)``, with a user object and
the token timestamp, or ``(None, None)`` if both were not found.
"""
@classmethod
def get_by_auth_password(cls, auth_id, password):
"""Returns a user object, validating password.
:param auth_id:
Authentication id.
:param password:
Password to be checked.
:returns:
A user object, if found and password matches.
:raises:
``auth.InvalidAuthIdError`` or ``auth.InvalidPasswordError``.
"""
@classmethod
def create_auth_token(cls, user_id):
"""Creates a new authorization token for a given user ID.
:param user_id:
User unique ID.
:returns:
A string with the authorization token.
"""
@classmethod
def delete_auth_token(cls, user_id, token):
"""Deletes a given authorization token.
:param user_id:
User unique ID.
:param token:
A string with the authorization token.
"""
Thank you for any answer or comment about this
It's both illegal and not recommended.
If you'd like your User
base class to be used in different applications, you should inherit it and override needed parts in THAT app. Do not do importing this way.