def add_openid_attribute_exchange(request, response, data):
 try:
  ax_request = ax.FetchRequest.fromOpenIDRequest(request)
 except ax.AXError:
  pass
 else:
  ax_response = ax.FetchResponse()
  if (ax_request and ax_request.requested_attributes):
   for type_uri in ax_request.requested_attributes.iterkeys():
    email_schema = 'http://axschema.org/contact/email'
    name_schema = 'http://axschema.org/namePerson'
    if ((type_uri == email_schema) and ('email' in data)):
     ax_response.addValue(email_schema, data['email'])
    elif ((type_uri == name_schema) and ('fullname' in data)):
     ax_response.addValue(name_schema, data['fullname'])
   ax_response.toMessage(response.fields)

def add_openid_attribute_exchange ( request , response , data ) : try : ax_request = ax . FetchRequest . fromOpenIDRequest ( request ) except ax . AXError : pass else : ax_response = ax . FetchResponse ( ) if ( ax_request and ax_request . requested_attributes ) : for type_uri in ax_request . requested_attributes . iterkeys ( ) : email_schema = 'http://axschema.org/contact/email' name_schema = 'http://axschema.org/namePerson' if ( ( type_uri == email_schema ) and ( 'email' in data ) ) : ax_response . addValue ( email_schema , data [ 'email' ] ) elif ( ( type_uri == name_schema ) and ( 'fullname' in data ) ) : ax_response . addValue ( name_schema , data [ 'fullname' ] ) ax_response . toMessage ( response . fields )
add attribute exchange fields to the response if requested .