Package openid :: Package extensions :: Module sreg :: Class SRegRequest
[hide private]
[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='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__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

    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 [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
source code
Static Methods [hide private]
str
_getSRegNS(message)
Extract the simple registration namespace URI from the given OpenID message.
source code
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='http://openid.net/extensions/sreg/1.1')
(Constructor)

source code 

Initialize an empty simple registration request

Overrides: object.__init__

_getSRegNS(message)
Static Method

source code 

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)

Parameters:
  • message (openid.message.Message) - The OpenID message from which to parse simple registration fields. This may be a request or response message.
Returns: str
the sreg namespace URI for the supplied message. The message may be modified to define a simple registration namespace.
Raises:
  • ValueError - when using OpenID 1 if the message defines the 'sreg' alias to be something other than a simple registration type.

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