Module Expr Str Import alias TryExcept body ImportFrom alias handlers ExceptHandler type NameLoad body ImportFrom alias ImportFrom alias ImportFrom alias ClassDef bases AttributeLoad NameLoad attr body Expr Str FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad keyword Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore Lambda arguments args defaults IfExp UnaryOpNot Call AttributeLoad AttributeLoad NameLoad attr attr Call AttributeLoad NameLoad attr NameLoad Return CompareIsNot Call AttributeLoad NameLoad attr NameLoad NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore ListComp Call AttributeLoad NameLoad attr NameLoad NameLoad comprehension NameStore NameLoad Assign NameStore ListComp Call NameLoad keyword NameLoad comprehension NameStore NameLoad Assign NameStore Lambda arguments args NameParam defaults IfExp UnaryOpNot Call AttributeLoad AttributeLoad NameLoad attr attr Call AttributeLoad NameLoad attr NameLoad Assign NameStore ListComp Call AttributeLoad NameLoad attr Lambda arguments args defaults Call NameLoad NameLoad comprehension NameStore NameLoad If CompareNotEq NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr GeneratorExp NameLoad comprehension NameStore NameLoad NameLoad Return TupleLoad NameLoad ListComp Call AttributeLoad NameLoad attr comprehension NameStore NameLoad CompareNotIn NameLoad NameLoad Return TupleLoad NameLoad ListLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr GeneratorExp Call AttributeLoad NameLoad attr NameLoad NameLoad comprehension NameStore NameLoad decorator_list NameLoad decorator_list ClassDef bases AttributeLoad NameLoad attr body Expr Str Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr NameLoad BinOpMod Str TupleLoad Call NameLoad NameLoad NameLoad NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad body Expr Str Assign NameStore Call NameLoad NameLoad Assign NameStore BoolOpOr NameLoad Call AttributeLoad NameLoad attr keyword Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Assign NameStore Call NameLoad keyword NameLoad keyword NameLoad keyword NameLoad keyword NameLoad Expr Call AttributeLoad NameLoad attr Return NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad NameLoad NameLoad body Expr Str If BoolOpAnd NameLoad NameLoad NameLoad body Return Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad attr Assert BoolOpAnd NameLoad NameLoad Str Return Call AttributeLoad Call AttributeLoad NameLoad attr CompareEq AttributeLoad NameLoad attr NameLoad CompareEq AttributeLoad NameLoad attr NameLoad attr decorator_list NameLoad decorator_list ClassDef bases AttributeLoad NameLoad attr body Expr Str Assign NameStore NameLoad Assign NameStore NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Assign NameStore BinOpMod Str TupleLoad AttributeLoad AttributeLoad NameLoad attr attr NameLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad If NameLoad body Expr Call AttributeLoad NameLoad attr Return TupleLoad NameLoad NameLoad orelse Return TupleLoad NameLoad ListLoad Str decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return Call AttributeLoad Call AttributeLoad NameLoad attr CompareEq AttributeLoad NameLoad attr NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Str NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr ListLoad NameLoad NameLoad If BoolOpAnd NameLoad NameLoad body Assign NameStore Call NameLoad Call AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr Return TupleLoad NameLoad NameLoad Return TupleLoad NameLoad NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad If UnaryOpNot NameLoad body Raise Call AttributeLoad NameLoad attr If UnaryOpNot Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr body Raise Call AttributeLoad NameLoad attr Return NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Return CompareIsNot Call AttributeLoad AttributeLoad NameLoad attr attr keyword NameLoad keyword NameLoad keyword NameLoad NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str Return AttributeLoad Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Str attr decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults body Return Call AttributeLoad NameLoad attr NameLoad Str NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Expr Call AttributeLoad Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Str NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Str Return AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults body Return Call AttributeLoad NameLoad attr NameLoad Str NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Call AttributeLoad Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Str NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad kwarg body Expr Str Assert CompareIs Call AttributeLoad NameLoad attr Str NameLoad Str Assert UnaryOpNot Call NameLoad NameLoad NameLoad Str If CompareIn Str NameLoad body Assign SubscriptStore NameLoad Index Str Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Str keyword Num Assign SubscriptStore NameLoad Index Str ListLoad NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore ListLoad TupleLoad BinOpMod Str TupleLoad AttributeLoad NameLoad attr NameLoad Str If NameLoad body For NameStore NameLoad body Assign NameStore BinOpMod Str TupleLoad AttributeLoad NameLoad attr NameLoad SubscriptLoad NameLoad Index NameLoad Expr Call AttributeLoad NameLoad attr TupleLoad NameLoad NameLoad Assign TupleStore NameStore NameStore Call AttributeLoad AttributeLoad NameLoad attr attr GeneratorExp NameLoad comprehension TupleStore NameStore NameStore NameLoad If NameLoad body Expr Call AttributeLoad NameLoad attr Return TupleLoad NameLoad NameLoad orelse Assign NameStore ListComp NameLoad comprehension TupleStore NameStore NameStore NameLoad CompareIn NameLoad NameLoad Return TupleLoad NameLoad NameLoad decorator_list NameLoad decorator_list
N/A N/A 
    webapp2_extras.appengine.auth.models
    ====================================

    Auth related models.

    :copyright: 2011 by tipfy.org.
    :license: Apache Sotware License, see LICENSE for details.
 N/A time N/A N/A ndb model N/A N/A N/A ImportError N/A google.appengine.ext.ndb model webapp2_extras auth webapp2_extras security Unique N/A N/A model Model N/A N/A A model to store unique values.

    The only purpose of this model is to "reserve" values that must be unique
    within a given scope, as a workaround because datastore doesn't support
    the concept of uniqueness for entity properties.

    For example, suppose we have a model `User` with three properties that
    must be unique across a given group: `username`, `auth_id` and `email`::

        class User(model.Model):
            username = model.StringProperty(required=True)
            auth_id = model.StringProperty(required=True)
            email = model.StringProperty(required=True)

    To ensure property uniqueness when creating a new `User`, we first create
    `Unique` records for those properties, and if everything goes well we can
    save the new `User` record::

        @classmethod
        def create_user(cls, username, auth_id, email):
            # Assemble the unique values for a given class and attribute scope.
            uniques = [
                'User.username.%s' % username,
                'User.auth_id.%s' % auth_id,
                'User.email.%s' % email,
            ]

            # Create the unique username, auth_id and email.
            success, existing = Unique.create_multi(uniques)

            if success:
                # The unique values were created, so we can save the user.
                user = User(username=username, auth_id=auth_id, email=email)
                user.put()
                return user
            else:
                # At least one of the values is not unique.
                # Make a list of the property names that failed.
                props = [name.split('.', 2)[1] for name in uniques]
                raise ValueError('Properties %r are not unique.' % props)

    Based on the idea from http://goo.gl/pBQhB
     create N/A N/A cls value N/A N/A N/A Creates a new unique value.

        :param value:
            The value to be unique, as a string.

            The value should include the scope in which the value must be
            unique (ancestor, namespace, kind and/or property name).

            For example, for a unique property `email` from kind `User`, the
            value can be `User.email:me@myself.com`. In this case `User.email`
            is the scope, and `me@myself.com` is the value to be unique.
        :returns:
            True if the unique value was created, False otherwise.
         N/A entity N/A cls key N/A N/A model Key cls value N/A txn N/A N/A N/A N/A N/A N/A N/A N/A N/A entity key get N/A N/A entity put None N/A N/A N/A N/A model transaction txn None N/A classmethod create_multi N/A N/A cls values N/A N/A N/A Creates multiple unique values at once.

        :param values:
            A sequence of values to be unique. See :meth:`create`.
        :returns:
            A tuple (bool, list_of_keys). If all values were created, bool is
            True and list_of_keys is empty. If one or more values weren't
            created, bool is False and the list contains all the values that
            already existed in datastore during the creation attempt.
         N/A keys N/A N/A N/A model Key cls value N/A value values N/A entities N/A N/A cls key key N/A key keys N/A func N/A N/A N/A e N/A N/A N/A N/A N/A N/A e key get N/A N/A e put None N/A created N/A N/A N/A model transaction N/A N/A N/A N/A N/A func e N/A e entities N/A N/A created keys N/A N/A N/A N/A model delete_multi N/A k N/A k created k N/A N/A False N/A N/A N/A k id N/A k keys N/A k created N/A N/A True N/A N/A classmethod delete_multi N/A N/A cls values N/A N/A N/A Deletes multiple unique values at once.

        :param values:
            A sequence of values to be deleted.
         N/A N/A N/A model delete_multi N/A N/A N/A model Key cls v N/A v values N/A classmethod N/A UserToken N/A N/A model Model N/A N/A Stores validation tokens for users. N/A created N/A N/A model DateTimeProperty auto_now_add True N/A updated N/A N/A model DateTimeProperty auto_now True N/A user N/A N/A model StringProperty required True indexed False N/A subject N/A N/A model StringProperty required True N/A token N/A N/A model StringProperty required True get_key N/A N/A cls user subject token N/A N/A N/A Returns a token key.

        :param user:
            User unique ID.
        :param subject:
            The subject of the key. Examples:

            - 'auth'
            - 'signup'
        :param token:
            Randomly generated token.
        :returns:
            ``model.Key`` containing a string id in the following format:
            ``{user_id}.{subject}.{token}.``
         N/A N/A N/A model Key cls N/A %s.%s.%s N/A N/A str user subject token N/A classmethod create N/A N/A cls user subject token N/A None N/A N/A Creates a new token for the given user.

        :param user:
            User unique ID.
        :param subject:
            The subject of the key. Examples:

            - 'auth'
            - 'signup'
        :param token:
            Optionally an existing token may be provided.
            If None, a random token will be generated.
        :returns:
            The newly created :class:`UserToken`.
         N/A user N/A str user N/A token N/A token N/A N/A security generate_random_string entropy 128 N/A key N/A N/A cls get_key user subject token N/A entity N/A cls key key user user subject subject token token N/A N/A N/A entity put N/A entity N/A classmethod get N/A N/A cls user subject token N/A None None None N/A N/A Fetches a user token.

        :param user:
            User unique ID.
        :param subject:
            The subject of the key. Examples:

            - 'auth'
            - 'signup'
        :param token:
            The existing token needing verified.
        :returns:
            A :class:`UserToken` or None if the token does not exist.
         N/A N/A user subject token N/A N/A N/A N/A N/A N/A cls get_key user subject token get N/A N/A subject token subject and token must be provided to UserToken.get(). N/A N/A N/A N/A N/A cls query N/A N/A cls subject subject N/A N/A cls token token get N/A classmethod N/A User N/A N/A model Expando N/A N/A Stores user authentication credentials or authorization ids. N/A unique_model Unique N/A token_model UserToken N/A created N/A N/A model DateTimeProperty auto_now_add True N/A updated N/A N/A model DateTimeProperty auto_now True N/A auth_ids N/A N/A model StringProperty repeated True N/A password N/A N/A model StringProperty get_id N/A N/A self N/A N/A N/A Returns this user's unique ID, which can be an integer or string. N/A N/A N/A N/A self _key id N/A add_auth_id N/A N/A self auth_id N/A N/A N/A A helper method to add additional auth ids to a User

        :param auth_id:
            String representing a unique id for the user. Examples:

            - own:username
            - google:username
        :returns:
            A tuple (boolean, info). The boolean indicates if the user
            was saved. If creation succeeds, ``info`` is the user entity;
            otherwise it is a list of duplicated unique properties that
            caused creation to fail.
         N/A N/A N/A N/A self auth_ids append auth_id N/A unique N/A %s.auth_id:%s N/A N/A N/A self __class__ __name__ auth_id N/A ok N/A N/A N/A self unique_model create unique N/A ok N/A N/A N/A N/A self put N/A N/A True self N/A N/A N/A False N/A auth_id N/A get_by_auth_id N/A N/A cls auth_id N/A N/A N/A Returns a user object based on a auth_id.

        :param auth_id:
            String representing a unique id for the user. Examples:

            - own:username
            - google:username
        :returns:
            A user object.
         N/A N/A N/A N/A N/A cls query N/A N/A cls auth_ids auth_id get N/A classmethod get_by_auth_token N/A N/A cls user_id token N/A N/A N/A 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.
         N/A token_key N/A N/A N/A cls token_model get_key user_id auth token N/A user_key N/A N/A model Key cls user_id N/A N/A valid_token user N/A N/A model get_multi N/A token_key user_key N/A N/A valid_token user N/A N/A timestamp N/A int N/A N/A time mktime N/A N/A N/A valid_token created timetuple N/A N/A user timestamp N/A N/A None None N/A classmethod get_by_auth_password N/A N/A cls auth_id password N/A N/A N/A 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``.
         N/A user N/A N/A cls get_by_auth_id auth_id N/A N/A user N/A N/A N/A N/A auth InvalidAuthIdError N/A N/A N/A N/A security check_password_hash password N/A user password N/A N/A N/A N/A auth InvalidPasswordError N/A user N/A classmethod validate_token N/A N/A cls user_id subject token N/A N/A N/A Checks for existence of a token, given user_id, subject and token.

        :param user_id:
            User unique ID.
        :param subject:
            The subject of the key. Examples:

            - 'auth'
            - 'signup'
        :param token:
            The token string to be validated.
        :returns:
            A :class:`UserToken` or None if the token does not exist.
         N/A N/A N/A N/A N/A cls token_model get user user_id subject subject token token None N/A classmethod create_auth_token N/A N/A cls user_id N/A N/A N/A Creates a new authorization token for a given user ID.

        :param user_id:
            User unique ID.
        :returns:
            A string with the authorization token.
         N/A N/A N/A N/A N/A cls token_model create user_id auth token N/A classmethod validate_auth_token N/A N/A cls user_id token N/A N/A N/A N/A N/A cls validate_token user_id auth token N/A classmethod delete_auth_token N/A N/A cls user_id token N/A N/A N/A Deletes a given authorization token.

        :param user_id:
            User unique ID.
        :param token:
            A string with the authorization token.
         N/A N/A N/A N/A N/A N/A cls token_model get_key user_id auth token delete N/A classmethod create_signup_token N/A N/A cls user_id N/A N/A N/A entity N/A N/A N/A cls token_model create user_id signup N/A N/A entity token N/A classmethod validate_signup_token N/A N/A cls user_id token N/A N/A N/A N/A N/A cls validate_token user_id signup token N/A classmethod delete_signup_token N/A N/A cls user_id token N/A N/A N/A N/A N/A N/A N/A N/A cls token_model get_key user_id signup token delete N/A classmethod create_user N/A N/A cls auth_id unique_properties N/A None user_values N/A N/A Creates a new user.

        :param auth_id:
            A string that is unique to the user. Users may have multiple
            auth ids. Example auth ids:

            - own:username
            - own:email@example.com
            - google:username
            - yahoo:username

            The value of `auth_id` must be unique.
        :param unique_properties:
            Sequence of extra property names that must be unique.
        :param user_values:
            Keyword arguments to create a new user entity. Since the model is
            an ``Expando``, any provided custom properties will be saved.
            To hash a plain password, pass a keyword ``password_raw``.
        :returns:
            A tuple (boolean, info). The boolean indicates if the user
            was created. If creation succeeds, ``info`` is the user entity;
            otherwise it is a list of duplicated unique properties that
            caused creation to fail.
         N/A N/A N/A N/A user_values get password None Use password_raw instead of password to create new users. N/A N/A N/A isinstance auth_id list Creating a user with multiple auth_ids is not allowed, please provide a single auth_id. N/A N/A password_raw user_values N/A N/A N/A user_values N/A password N/A N/A security generate_password_hash N/A N/A user_values pop password_raw length 12 N/A N/A user_values N/A auth_ids N/A auth_id N/A user N/A cls user_values N/A uniques N/A N/A N/A %s.auth_id:%s N/A N/A cls __name__ auth_id auth_id N/A unique_properties N/A N/A name unique_properties N/A N/A key N/A %s.%s:%s N/A N/A cls __name__ name N/A user_values N/A name N/A N/A N/A uniques append N/A key name N/A N/A ok existing N/A N/A N/A cls unique_model create_multi N/A k N/A N/A k v uniques N/A ok N/A N/A N/A N/A user put N/A N/A True user N/A N/A properties N/A v N/A N/A k v uniques N/A k existing N/A N/A False properties N/A classmethod N/A