Package openid :: Package extensions :: 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
 
__init__(self, required=None, optional=None, policy_url=None, sreg_ns_uri='http://openid.net/extensions/sreg/1.1')
Initialize an empty simple registration request
source code
[str]
allRequestedFields(self)
A list of all of the simple registration fields that were requested, whether they were required or optional.
source code
bool
wereFieldsRequested(self)
Have any simple registration fields been requested?
source code
 
__contains__(self, field_name)
Was this field in the request?
source code

Inherited from extension.Extension: toMessage

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

    Consumer
 
requestField(self, field_name, required=False, strict=False)
Request the specified field from the OpenID user
source code
 
requestFields(self, field_names, required=False, strict=False)
Add the given list of fields to the request
source code
{str:str}
getExtensionArgs(self)
Get a dictionary of unqualified simple registration arguments representing this request.
source code
    Server
 
parseExtensionArgs(self, args, strict=False)
Parse the unqualified simple registration request parameters and add them to this object.
source code
Class Methods
    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
source code
Class Variables
  ns_alias = 'sreg'
Instance Variables
[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

Inherited from object: __class__

Method Details

__init__(self, required=None, optional=None, policy_url=None, sreg_ns_uri='http://openid.net/extensions/sreg/1.1')
(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=False)

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

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

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=False, strict=False)

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}
A dictionary of completely non-namespaced arguments to be added. For example, if the extension's alias is 'uncle', and this method returns {'meat':'Hot Rats'}, the final message will contain {'openid.uncle.meat':'Hot Rats'}
Overrides: extension.Extension.getExtensionArgs