Package openid :: Package extensions :: Module ax :: Class AXKeyValueMessage
[hide private]
[frames] | no frames]

Class AXKeyValueMessage

source code

         object --+        
                  |        
extension.Extension --+    
                      |    
              AXMessage --+
                          |
                         AXKeyValueMessage

An abstract class that implements a message that has attribute keys and values. It contains the common code between fetch_response and store_request.

Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
addValue(self, type_uri, value)
Add a single value for the given attribute type to the message.
source code
 
setValues(self, type_uri, values)
Set the values for the given attribute type.
source code
 
_getExtensionKVArgs(self, aliases=None)
Get the extension arguments for the key/value pairs contained in this message.
source code
 
parseExtensionArgs(self, ax_args)
Parse attribute exchange key/value arguments into this object.
source code
unicode or NoneType
getSingle(self, type_uri, default=None)
Get a single value for an attribute.
source code
[unicode]
get(self, type_uri)
Get the list of values for this attribute in the fetch_response.
source code
 
count(self, type_uri)
Get the number of responses for a particular attribute in this fetch_response message.
source code

Inherited from AXMessage (private): _checkMode, _newArgs

Inherited from extension.Extension: getExtensionArgs, toMessage

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

Class Variables [hide private]

Inherited from AXMessage: mode, ns_alias, ns_uri

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

addValue(self, type_uri, value)

source code 

Add a single value for the given attribute type to the message. If there are already values specified for this type, this value will be sent in addition to the values already specified.

Parameters:
  • type_uri - The URI for the attribute
  • value (unicode) - The value to add to the response to the relying party for this attribute
Returns:
None

setValues(self, type_uri, values)

source code 

Set the values for the given attribute type. This replaces any values that have already been set for this attribute.

Parameters:
  • type_uri - The URI for the attribute
  • values ([unicode]) - A list of values to send for this attribute.

_getExtensionKVArgs(self, aliases=None)

source code 

Get the extension arguments for the key/value pairs contained in this message.

Parameters:
  • aliases - An alias mapping. Set to None if you don't care about the aliases for this request.

parseExtensionArgs(self, ax_args)

source code 

Parse attribute exchange key/value arguments into this object.

Parameters:
  • ax_args ({unicode:unicode}) - The attribute exchange fetch_response arguments, with namespacing removed.
Returns:
None
Raises:
  • ValueError - If the message has bad values for particular fields
  • KeyError - If the namespace mapping is bad or required arguments are missing

getSingle(self, type_uri, default=None)

source code 

Get a single value for an attribute. If no value was sent for this attribute, use the supplied default. If there is more than one value for this attribute, this method will fail.

Parameters:
  • type_uri (str) - The URI for the attribute
  • default - The value to return if the attribute was not sent in the fetch_response.
Returns: unicode or NoneType
The value of the attribute in the fetch_response message, or the default supplied
Raises:
  • ValueError - If there is more than one value for this parameter in the fetch_response message.
  • KeyError - If the attribute was not sent in this response

get(self, type_uri)

source code 

Get the list of values for this attribute in the fetch_response.

XXX: what to do if the values are not present? default parameter? this is funny because it's always supposed to return a list, so the default may break that, though it's provided by the user's code, so it might be okay. If no default is supplied, should the return be None or []?

Parameters:
  • type_uri - The URI of the attribute
Returns: [unicode]
The list of values for this attribute in the response. May be an empty list.
Raises:
  • KeyError - If the attribute was not sent in the response

count(self, type_uri)

source code 

Get the number of responses for a particular attribute in this fetch_response message.

Parameters:
  • type_uri - The URI of the attribute
Returns:
The number of values sent for this attribute
Raises:
  • KeyError - If the attribute was not sent in the response. KeyError will not be raised if the number of values was zero.