1 from openid
import message
as message_module
3 class Extension(object):
4 """An interface for OpenID extensions.
6 @ivar ns_uri: The namespace to which to add the arguments for this
12 def getExtensionArgs(self
):
13 """Get the string arguments that should be added to an OpenID
14 message for this extension.
16 @returns: A dictionary of completely non-namespaced arguments
17 to be added. For example, if the extension's alias is
18 'uncle', and this method returns {'meat':'Hot Rats'}, the
19 final message will contain {'openid.uncle.meat':'Hot Rats'}
21 raise NotImplementedError
23 def toMessage(self
, message
=None):
24 """Add the arguments from this extension to the provided
25 message, or create a new message containing only those
28 @returns: The message with the extension arguments added
31 warnings
.warn('Passing None to Extension.toMessage is deprecated. '
32 'Creating a message assuming you want OpenID 2.',
33 DeprecationWarning, stacklevel
=2)
34 message
= message_module
.Message(message_module
.OPENID2_NS
)
36 implicit
= message
.isOpenID1()
39 message
.namespaces
.addAlias(self
.ns_uri
, self
.ns_alias
,
42 if message
.namespaces
.getAlias(self
.ns_uri
) != self
.ns_alias
:
45 message
.updateArgs(self
.ns_uri
, self
.getExtensionArgs())