Законно ли выполнять импорт следующим образом:
from webapp2_extras.appengine.auth.models import User as webapp2.User
Я бы хотел сослаться на объект как webapp2.User, хотя технически это не так.Это потому, что есть другой объект с именем User, поэтому я бы назвал пользователей с этой моделью, например, webapp2_user, в отличие от fbuser (пользователь facebook, который приходит через «логин с facebook») и пользователей Google.Это хороший класс, поскольку он допускает подключение вашей учетной записи Google или Facebook к этой модели:
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.
"""
Спасибо за любой ответ или комментарий по этому поводу