Module Expr Str ImportFrom alias alias ImportFrom alias Import alias TryExcept body Expr NameLoad handlers ExceptHandler type NameLoad body Assign NameStore TupleLoad NameLoad NameLoad Assign NameStore ListLoad Str Str Str Str Str Str Str Assign NameStore Dict Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str FunctionDef arguments args NameParam defaults body Expr Str If CompareNotIn NameLoad NameLoad body Raise Call NameLoad BinOpMod Str TupleLoad NameLoad decorator_list Assign NameStore Str Assign NameStore Str Assign NameStore NameLoad TryExcept body Expr Call NameLoad NameLoad Str handlers ExceptHandler type NameLoad name NameStore body Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad Str Call NameLoad NameLoad FunctionDef arguments args NameParam defaults body Expr Str Return BoolOpOr Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr NameLoad decorator_list ClassDef bases NameLoad body Expr Str decorator_list FunctionDef arguments args NameParam defaults body Expr Str For NameStore ListLoad NameLoad NameLoad body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad If CompareIsNot NameLoad NameLoad body Break orelse Assign NameStore NameLoad TryExcept body Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Str handlers ExceptHandler type NameLoad name NameStore body Raise Call NameLoad NameLoad Return NameLoad decorator_list ClassDef bases NameLoad body Expr Str Assign NameStore Str FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad NameLoad NameLoad body Expr Str Expr Call AttributeLoad NameLoad attr NameLoad Assign AttributeStore NameLoad attr ListLoad Assign AttributeStore NameLoad attr ListLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad If NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad keyword NameLoad keyword NameLoad If NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad keyword NameLoad keyword NameLoad decorator_list Assign NameStore Call NameLoad NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list Assign NameStore Call NameLoad NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str For NameStore ListLoad Str Str body Assign NameStore CompareEq NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad If NameLoad body For NameStore Call AttributeLoad NameLoad attr Str body TryExcept body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad handlers ExceptHandler type NameLoad body If NameLoad body Raise Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return BinOpAdd AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call NameLoad Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return BoolOpOr CompareIn NameLoad AttributeLoad NameLoad attr CompareIn NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str Expr Call NameLoad NameLoad If NameLoad body If BoolOpOr CompareIn NameLoad AttributeLoad NameLoad attr CompareIn NameLoad AttributeLoad NameLoad attr body Raise Call NameLoad Str orelse If CompareIn NameLoad AttributeLoad NameLoad attr body Return If CompareIn NameLoad AttributeLoad NameLoad attr body If NameLoad body Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad orelse Return If NameLoad body Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad orelse Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str If Call NameLoad NameLoad NameLoad body Raise Call NameLoad BinOpMod Str TupleLoad Call NameLoad NameLoad For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad keyword NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Dict If AttributeLoad NameLoad attr body Assign SubscriptStore NameLoad Index Str Call AttributeLoad Str attr AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body Assign SubscriptStore NameLoad Index Str Call AttributeLoad Str attr AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body Assign SubscriptStore NameLoad Index Str AttributeLoad NameLoad attr Return NameLoad decorator_list decorator_list ClassDef bases NameLoad body Expr Str Assign NameStore Str FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad If CompareIs NameLoad NameLoad body Assign AttributeStore NameLoad attr Dict orelse Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad Assign AttributeStore NameLoad attr AttributeLoad NameLoad attr For NameStore Call AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad NameLoad attr NameLoad If CompareIsNot NameLoad NameLoad body Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad NameLoad Return NameLoad decorator_list Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str Assign NameStore Call NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr If NameLoad body Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr orelse Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr If UnaryOpNot NameLoad body Return NameLoad For NameStore NameLoad body If CompareIn NameLoad NameLoad body Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad SubscriptLoad NameLoad Index NameLoad Return NameLoad decorator_list Assign NameStore Call NameLoad NameLoad FunctionDef arguments args NameParam defaults body Expr Str Return AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str Expr Call NameLoad NameLoad Return Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call NameLoad Call AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam defaults body Return Call NameLoad Call AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam defaults body Return Call NameLoad Call AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam defaults body Return Call NameLoad Call AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Return CompareIn NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Call NameLoad NameLoad Return CompareIn NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Return Call NameLoad AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Call NameLoad NameLoad Return SubscriptLoad AttributeLoad NameLoad attr Index NameLoad decorator_list FunctionDef arguments args NameParam defaults body Return Call NameLoad AttributeLoad NameLoad attr decorator_list decorator_list
N/A N/A Simple registration request and response parsing and object representation

This module contains objects representing simple registration requests
and responses that can be used with both OpenID relying parties and
OpenID providers.

  1. The relying party creates a request object and adds it to the
     C{L{AuthRequest<openid.consumer.consumer.AuthRequest>}} object
     before making the C{checkid_} request to the OpenID provider::

      auth_request.addExtension(SRegRequest(required=['email']))

  2. The OpenID provider extracts the simple registration request from
     the OpenID request using C{L{SRegRequest.fromOpenIDRequest}},
     gets the user's approval and data, creates a C{L{SRegResponse}}
     object and adds it to the C{id_res} response::

      sreg_req = SRegRequest.fromOpenIDRequest(checkid_request)
      # [ get the user's approval and data, informing the user that
      #   the fields in sreg_response were requested ]
      sreg_resp = SRegResponse.extractResponse(sreg_req, user_data)
      sreg_resp.toMessage(openid_response.fields)

  3. The relying party uses C{L{SRegResponse.fromSuccessResponse}} to
     extract the data from the OpenID response::

      sreg_resp = SRegResponse.fromSuccessResponse(success_response)

@since: 2.0

@var sreg_data_fields: The names of the data fields that are listed in
    the sreg spec, and a description of them in English

@var sreg_uri: The preferred URI to use for the simple registration
    namespace and XRD Type value
 openid.message registerNamespaceAlias NamespaceAliasRegistrationError openid.extension Extension N/A logging N/A N/A N/A str N/A N/A N/A NameError N/A N/A str N/A str str N/A __all__ N/A SRegRequest SRegResponse data_fields ns_uri ns_uri_1_0 ns_uri_1_1 supportsSReg N/A data_fields N/A fullname nickname dob email gender postcode country language timezone Full Name Nickname Date of Birth E-mail Address Gender Postal Code Country Language Time Zone checkFieldName N/A N/A field_name N/A N/A N/A Check to see that the given value is a valid simple
    registration data field name.

    @raise ValueError: if the field name is not a valid simple
        registration data field name
     N/A N/A field_name data_fields N/A N/A N/A ValueError N/A %r is not a defined simple registration field N/A field_name N/A N/A ns_uri_1_0 http://openid.net/sreg/1.0 N/A ns_uri_1_1 http://openid.net/extensions/sreg/1.1 N/A ns_uri ns_uri_1_1 N/A N/A N/A N/A registerNamespaceAlias ns_uri_1_1 sreg N/A N/A N/A NamespaceAliasRegistrationError N/A e N/A N/A N/A N/A logging exception N/A registerNamespaceAlias(%r, %r) failed: %s N/A ns_uri_1_1 sreg N/A str e supportsSReg N/A N/A endpoint N/A N/A N/A Does the given endpoint advertise support for simple
    registration?

    @param endpoint: The endpoint object as returned by OpenID discovery
    @type endpoint: openid.consumer.discover.OpenIDEndpoint

    @returns: Whether an sreg type was advertised by the endpoint
    @rtype: bool
     N/A N/A N/A N/A endpoint usesExtension ns_uri_1_1 N/A N/A endpoint usesExtension ns_uri_1_0 N/A SRegNamespaceError N/A ValueError N/A N/A The simple registration namespace was not found and could not
    be created using the expected name (there's another extension
    using the name 'sreg')

    This is not I{illegal}, for OpenID 2, although it probably
    indicates a problem, since it's not expected that other extensions
    will re-use the alias that is in use for OpenID 1.

    If this is an OpenID 1 request, then there is no recourse. This
    should not happen unless some code has modified the namespaces for
    the message that is being processed.
     N/A getSRegNS N/A N/A message N/A N/A N/A Extract the simple registration namespace URI from the given
    OpenID message. Handles OpenID 1 and 2, as well as both sreg
    namespace URIs found in the wild, as well as missing namespace
    definitions (for OpenID 1)

    @param message: The OpenID message from which to parse simple
        registration fields. This may be a request or response message.
    @type message: C{L{openid.message.Message}}

    @returns: the sreg namespace URI for the supplied message. The
        message may be modified to define a simple registration
        namespace.
    @rtype: C{str}

    @raise ValueError: when using OpenID 1 if the message defines
        the 'sreg' alias to be something other than a simple
        registration type.
     N/A sreg_ns_uri N/A ns_uri_1_1 ns_uri_1_0 N/A N/A alias N/A N/A N/A message namespaces getAlias sreg_ns_uri N/A N/A alias None N/A N/A N/A N/A sreg_ns_uri ns_uri_1_1 N/A N/A N/A N/A N/A N/A message namespaces addAlias ns_uri_1_1 sreg N/A N/A N/A KeyError N/A why N/A N/A N/A SRegNamespaceError why N/A sreg_ns_uri N/A SRegRequest N/A Extension N/A N/A An object to hold the state of a simple registration request.

    @ivar required: A list of the required fields in this simple
        registration request
    @type required: [str]

    @ivar optional: A list of the optional fields in this simple
        registration request
    @type optional: [str]

    @ivar policy_url: The policy URL that was provided with the request
    @type policy_url: str or NoneType

    @group Consumer: requestField, requestFields, getExtensionArgs, addToOpenIDRequest
    @group Server: fromOpenIDRequest, parseExtensionArgs
     N/A ns_alias sreg __init__ N/A N/A self required optional policy_url sreg_ns_uri N/A None None None ns_uri N/A N/A Initialize an empty simple registration request N/A N/A N/A Extension __init__ self N/A N/A self required N/A N/A N/A self optional N/A N/A N/A self policy_url policy_url N/A N/A self ns_uri sreg_ns_uri N/A required N/A N/A N/A N/A self requestFields required required True strict True N/A optional N/A N/A N/A N/A self requestFields optional required False strict True N/A N/A _getSRegNS N/A staticmethod getSRegNS fromOpenIDRequest N/A N/A cls request N/A N/A N/A Create a simple registration request that contains the
        fields that were requested in the OpenID request with the
        given arguments

        @param request: The OpenID request
        @type request: openid.server.CheckIDRequest

        @returns: The newly created simple registration request
        @rtype: C{L{SRegRequest}}
         N/A self N/A cls N/A message N/A N/A N/A request message copy N/A N/A self ns_uri N/A N/A self _getSRegNS message N/A args N/A N/A message getArgs N/A self ns_uri N/A N/A N/A self parseExtensionArgs args N/A self N/A N/A fromOpenIDRequest N/A classmethod fromOpenIDRequest parseExtensionArgs N/A N/A self args strict N/A False N/A N/A Parse the unqualified simple registration request
        parameters and add them to this object.

        This method is essentially the inverse of
        C{L{getExtensionArgs}}. This method restores the serialized simple
        registration request fields.

        If you are extracting arguments from a standard OpenID
        checkid_* request, you probably want to use C{L{fromOpenIDRequest}},
        which will extract the sreg namespace and arguments from the
        OpenID request. This method is intended for cases where the
        OpenID server needs more control over how the arguments are
        parsed than that method provides.

        >>> args = message.getArgs(ns_uri)
        >>> request.parseExtensionArgs(args)

        @param args: The unqualified simple registration arguments
        @type args: {str:str}

        @param strict: Whether requests with fields that are not
            defined in the simple registration specification should be
            tolerated (and ignored)
        @type strict: bool

        @returns: None; updates this object
         N/A list_name N/A required optional N/A N/A required N/A list_name required N/A items N/A N/A args get list_name N/A items N/A N/A field_name N/A N/A items split , N/A N/A N/A N/A N/A N/A self requestField field_name required strict N/A N/A N/A ValueError N/A N/A strict N/A N/A N/A N/A self policy_url N/A N/A args get policy_url N/A allRequestedFields N/A N/A self N/A N/A N/A A list of all of the simple registration fields that were
        requested, whether they were required or optional.

        @rtype: [str]
         N/A N/A N/A self required N/A self optional N/A wereFieldsRequested N/A N/A self N/A N/A N/A Have any simple registration fields been requested?

        @rtype: bool
         N/A N/A bool N/A N/A self allRequestedFields N/A __contains__ N/A N/A self field_name N/A N/A N/A Was this field in the request? N/A N/A N/A field_name N/A self required N/A field_name N/A self optional N/A requestField N/A N/A self field_name required strict N/A False False N/A N/A Request the specified field from the OpenID user

        @param field_name: the unqualified simple registration field name
        @type field_name: str

        @param required: whether the given field should be presented
            to the user as being a required to successfully complete
            the request

        @param strict: whether to raise an exception when a field is
            added to a request more than once

        @raise ValueError: when the field requested is not a simple
            registration field or strict is set and the field was
            requested more than once
         N/A N/A checkFieldName field_name N/A strict N/A N/A N/A N/A field_name N/A self required N/A field_name N/A self optional N/A N/A N/A ValueError That field has already been requested N/A N/A N/A field_name N/A self required N/A N/A N/A N/A field_name N/A self optional N/A N/A required N/A N/A N/A N/A N/A self optional remove field_name N/A N/A N/A required N/A N/A N/A N/A N/A self required append field_name N/A N/A N/A N/A N/A self optional append field_name N/A requestFields N/A N/A self field_names required strict N/A False False N/A N/A Add the given list of fields to the request

        @param field_names: The simple registration data fields to request
        @type field_names: [str]

        @param required: Whether these values should be presented to
            the user as required

        @param strict: whether to raise an exception when a field is
            added to a request more than once

        @raise ValueError: when a field requested is not a simple
            registration field or strict is set and a field was
            requested more than once
         N/A N/A isinstance field_names str N/A N/A N/A TypeError N/A Fields should be passed as a list of strings (not %r) N/A N/A type field_names N/A field_name field_names N/A N/A N/A N/A self requestField field_name required strict strict N/A getExtensionArgs N/A N/A self N/A N/A N/A Get a dictionary of unqualified simple registration
        arguments representing this request.

        This method is essentially the inverse of
        C{L{parseExtensionArgs}}. This method serializes the simple
        registration request fields.

        @rtype: {str:str}
         N/A args N/A N/A N/A self required N/A N/A N/A args N/A required N/A N/A , join N/A self required N/A N/A self optional N/A N/A N/A args N/A optional N/A N/A , join N/A self optional N/A N/A self policy_url N/A N/A N/A args N/A policy_url N/A self policy_url N/A args N/A N/A SRegResponse N/A Extension N/A N/A Represents the data returned in a simple registration response
    inside of an OpenID C{id_res} response. This object will be
    created by the OpenID server, added to the C{id_res} response
    object, and then extracted from the C{id_res} message by the
    Consumer.

    @ivar data: The simple registration data, keyed by the unqualified
        simple registration name of the field (i.e. nickname is keyed
        by C{'nickname'})

    @ivar ns_uri: The URI under which the simple registration data was
        stored in the response message.

    @group Server: extractResponse
    @group Consumer: fromSuccessResponse
    @group Read-only dictionary interface: keys, iterkeys, items, iteritems,
        __iter__, get, __getitem__, keys, has_key
     N/A ns_alias sreg __init__ N/A N/A self data sreg_ns_uri N/A None ns_uri N/A N/A N/A N/A Extension __init__ self N/A N/A data None N/A N/A N/A self data N/A N/A N/A N/A self data data N/A N/A self ns_uri sreg_ns_uri N/A extractResponse N/A N/A cls request data N/A N/A N/A Take a C{L{SRegRequest}} and a dictionary of simple
        registration values and create a C{L{SRegResponse}}
        object containing that data.

        @param request: The simple registration request object
        @type request: SRegRequest

        @param data: The simple registration data for this
            response, as a dictionary from unqualified simple
            registration field name to string (unicode) value. For
            instance, the nickname should be stored under the key
            'nickname'.
        @type data: {str:str}

        @returns: a simple registration response object
        @rtype: SRegResponse
         N/A self N/A cls N/A N/A self ns_uri N/A request ns_uri N/A field N/A N/A request allRequestedFields N/A N/A value N/A N/A data get field N/A N/A value None N/A N/A N/A N/A self data N/A field value N/A self N/A N/A extractResponse N/A classmethod extractResponse N/A _getSRegNS N/A staticmethod getSRegNS fromSuccessResponse N/A N/A cls success_response signed_only N/A True N/A N/A Create a C{L{SRegResponse}} object from a successful OpenID
        library response
        (C{L{openid.consumer.consumer.SuccessResponse}}) response
        message

        @param success_response: A SuccessResponse from consumer.complete()
        @type success_response: C{L{openid.consumer.consumer.SuccessResponse}}

        @param signed_only: Whether to process only data that was
            signed in the id_res message from the server.
        @type signed_only: bool

        @rtype: SRegResponse
        @returns: A simple registration response containing the data
            that was supplied with the C{id_res} response.
         N/A self N/A cls N/A N/A self ns_uri N/A N/A self _getSRegNS N/A success_response message N/A signed_only N/A N/A args N/A N/A success_response getSignedNS N/A self ns_uri N/A N/A args N/A N/A N/A success_response message getArgs N/A self ns_uri N/A N/A args N/A N/A None N/A field_name data_fields N/A N/A N/A field_name args N/A N/A N/A N/A self data N/A field_name N/A args N/A field_name N/A self N/A N/A fromSuccessResponse N/A classmethod fromSuccessResponse getExtensionArgs N/A N/A self N/A N/A N/A Get the fields to put in the simple registration namespace
        when adding them to an id_res message.

        @see: openid.extension
         N/A N/A self data N/A get N/A N/A self field_name default N/A None N/A N/A Like dict.get, except that it checks that the field name is
        defined by the simple registration specification N/A N/A checkFieldName field_name N/A N/A N/A N/A self data get field_name default N/A items N/A N/A self N/A N/A N/A All of the data values in this simple registration response
         N/A N/A list N/A N/A N/A self data items N/A iteritems N/A N/A self N/A N/A N/A N/A iter N/A N/A N/A self data items N/A keys N/A N/A self N/A N/A N/A N/A list N/A N/A N/A self data keys N/A iterkeys N/A N/A self N/A N/A N/A N/A iter N/A N/A N/A self data keys N/A has_key N/A N/A self key N/A N/A N/A N/A key self N/A __contains__ N/A N/A self field_name N/A N/A N/A N/A checkFieldName field_name N/A N/A field_name N/A self data N/A __iter__ N/A N/A self N/A N/A N/A N/A iter N/A self data N/A __getitem__ N/A N/A self field_name N/A N/A N/A N/A checkFieldName field_name N/A N/A N/A self data N/A field_name N/A __bool__ N/A N/A self N/A N/A N/A N/A bool N/A self data N/A N/A