Google Code offered in: English - Español - 日本語 - 한국어 - Português - Pусский - 中文(简体) - 中文(繁體)
An instance of the User class represents an authenticated user of the app.
User
is provided by the google.appengine.api.users
module.
An instance of the User class represents an authenticated user of the application. The user is authenticated using the authentication option set for the app: either Google Accounts, Google Apps account, or OpenID. An app can get a User instance that represents the user currently signed in to the application by calling the constructor with no arguments, or by calling the users.get_current_user() function. If the current user is not signed in, the User constructor raises a UserNotFoundError. (users.get_current_user() does not raise an exception if the user is not signed in.)
User objects are comparable. If two User objects are equal, then both objects represent the same user.
A User object can be the value of a datastore entity property. See Types and Property Classes.
Note: A user can change the email address for a Google account. If you need an ID that represents the user regardless of account changes, use user_id()
.
Represents an authenticated user of the app.
Arguments:
The email address of the desired user. If omitted, the object will represent the current user (the user making the request). If no address is given and the current user is not signed in, a UserNotFoundError is raised.
Only RFC compliant email addresses can match a real user. You can, however, store non-RFC-compliant email addresses in the datastore.
The OpenID identifier of the desired user.
A User instance provides the following methods:
Returns the "nickname" of the user, a displayable name. For Google Accounts users, the nickname is either the "name" portion of the user's email address if the address is in the same domain as the application, or the user's full email address otherwise. For OpenID users, the nickname is the OpenID identifier.
Returns the email address of the user. If you use OpenID, you should not rely on this email address to be correct. Applications should use nickname for displayable names.
If the email address is associated with a Google account, user_id
returns the unique permanent ID of the user, a str
. This ID is always the same for the user regardless of whether the user changes her email address.
If the email address is not associated with a Google account, user_id
returns None
.
Note: If your application constructs the User
instance, the API will not set a value for user_id
and it returns None
.
Returns the user's OpenID identifier.
Returns the URL of the user's OpenID provider.