Package openid :: Module sreg :: Class SRegRequest
[frames] | no frames]

Class SRegRequest

source code

         object --+    
                  |    
extension.Extension --+
                      |
                     SRegRequest

An object to hold the state of a simple registration request.

Instance Methods [hide private]
  __init__(self, required=None, optional=None, policy_url=None, sreg_ns_uri=ns_uri)
Initialize an empty simple registration request
[str] allRequestedFields(self)
A list of all of the simple registration fields that were requested, whether they were required or optional.
bool wereFieldsRequested(self)
Have any simple registration fields been requested?
  __contains__(self, field_name)
Was this field in the request?

Inherited from extension.Extension: toMessage

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

    Consumer
  requestField(self, field_name, required=True, strict=True)
Request the specified field from the OpenID user
  requestFields(self, field_names, required=True, strict=True)
Add the given list of fields to the request
{str:str} getExtensionArgs(self)
Get a dictionary of unqualified simple registration arguments representing this request.
    Server
  parseExtensionArgs(self, args, strict=True)
Parse the unqualified simple registration request parameters and add them to this object.

Class Methods [hide private]
    Server
SRegRequest fromOpenIDRequest(cls, request)
Create a simple registration request that contains the fields that were requested in the OpenID request with the given arguments

Class Variables [hide private]
  ns_alias = 'sreg'

Instance Variables [hide private]
[str] optional
A list of the optional fields in this simple registration request
str or NoneType policy_url
The policy URL that was provided with the request
[str] required
A list of the required fields in this simple registration request

Inherited from extension.Extension: ns_uri


Properties [hide private]

Inherited from object: __class__


Method Details [hide private]

__init__(self, required=None, optional=None, policy_url=None, sreg_ns_uri=ns_uri)
(Constructor)

source code 

Initialize an empty simple registration request
Overrides: object.__init__

fromOpenIDRequest(cls, request)
Class Method

source code 

Create a simple registration request that contains the fields that were requested in the OpenID request with the given arguments
Parameters:
  • request (openid.server.CheckIDRequest) - The OpenID request
Returns: SRegRequest
The newly created simple registration request

parseExtensionArgs(self, args, strict=True)

source code 

Parse the unqualified simple registration request parameters and add them to this object.

This method is essentially the inverse of 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 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)
Parameters:
  • args ({str:str}) - The unqualified simple registration arguments
  • strict (bool) - Whether requests with fields that are not defined in the simple registration specification should be tolerated (and ignored)
Returns:
None; updates this object

allRequestedFields(self)

source code 

A list of all of the simple registration fields that were requested, whether they were required or optional.
Returns: [str]

wereFieldsRequested(self)

source code 

Have any simple registration fields been requested?
Returns: bool

__contains__(self, field_name)
(In operator)

source code 

Was this field in the request?

requestField(self, field_name, required=True, strict=True)

source code 

Request the specified field from the OpenID user
Parameters:
  • field_name (str) - the unqualified simple registration field name
  • required - whether the given field should be presented to the user as being a required to successfully complete the request
  • strict - whether to raise an exception when a field is added to a request more than once
Raises:
  • ValueError - when the field requested is not a simple registration field or strict is set and the field was requested more than once

requestFields(self, field_names, required=True, strict=True)

source code 

Add the given list of fields to the request
Parameters:
  • field_names ([str]) - The simple registration data fields to request
  • required - Whether these values should be presented to the user as required
  • strict - whether to raise an exception when a field is added to a request more than once
Raises:
  • ValueError - when a field requested is not a simple registration field or strict is set and a field was requested more than once

getExtensionArgs(self)

source code 

Get a dictionary of unqualified simple registration arguments representing this request.

This method is essentially the inverse of parseExtensionArgs. This method serializes the simple registration request fields.
Returns: {str:str}
Overrides: extension.Extension.getExtensionArgs

Class Variable Details [hide private]

ns_alias

Value:
'sreg'                                                                 
      

Instance Variable Details [hide private]

optional


A list of the optional fields in this simple registration request
Type:
[str]

policy_url


The policy URL that was provided with the request
Type:
str or NoneType

required


A list of the required fields in this simple registration request
Type:
[str]