Comment out the 'loadtest' backend in the 'counter' backend sample so that it does...
[gae-samples.git] / openid-consumer / openid / extension.py
blob403f0561b501e545e9c2b68a02759113865576ea
1 from openid.message import Message
3 class Extension(object):
4 """An interface for OpenID extensions.
6 @ivar ns_uri: The namespace to which to add the arguments for this
7 extension
8 """
9 ns_uri = None
10 ns_alias = None
12 def getExtensionArgs(self):
13 """Get the string arguments that should be added to an OpenID
14 message for this extension.
15 """
16 raise NotImplementedError
18 def toMessage(self, message=None):
19 """Add the arguments from this extension to the provided
20 message, or create a new message containing only those
21 arguments.
23 @returns: The message with the extension arguments added
24 """
25 if message is None:
26 message = Message()
28 try:
29 message.namespaces.addAlias(self.ns_uri, self.ns_alias)
30 except KeyError:
31 if message.namespaces.getAlias(self.ns_uri) != self.ns_alias:
32 raise
34 message.updateArgs(self.ns_uri, self.getExtensionArgs())
35 return message