Commits

Anonymous committed d1ae9e8

[svn r31] sreg args was deprecated. use new way. tested on friendsnippets.

  • Participants
  • Parent commits 212e576

Comments (0)

Files changed (2)

 # -*- coding: utf-8 -*-
 from openid.store.interface import OpenIDStore
 from openid.association import Association as OIDAssociation
+from openid.association import Association
+from openid.extensions import sreg
+import openid.store
+
 from django.db.models.query import Q
 from django.conf import settings
 
-import openid.store
 
 # needed for some linux distributions like debian
 try:
     issued = int(time.time())
     return OpenID(
         openid_response.identity_url, issued, openid_response.signed_fields, 
-        openid_response.extensionResponse('sreg', False)
+         dict(sreg.SRegResponse.fromSuccessResponse(openid_response))
     )
 from openid.consumer.consumer import Consumer, \
     SUCCESS, CANCEL, FAILURE, SETUP_NEEDED
 from openid.consumer.discover import DiscoveryFailure
-
+from openid.extensions import sreg
 # needed for some linux distributions like debian
 try:
     from openid.yadis import xri
     # path, not a complete URL.
     return bool(next_url_re.match(next))
 
-def ask_openid(request, openid_url, redirect_to, on_failure=None, extension_args=None):
+def ask_openid(request, openid_url, redirect_to, on_failure=None, sreg_request=None):
     """ basic function to ask openid and return response """
 
     on_failure = on_failure or signin_failure
-    extension_args = extension_args or {}
-
+    
     trust_root = getattr(
         settings, 'OPENID_TRUST_ROOT', get_url_host(request) + '/'
     )
         msg =_("The OpenID %s was invalid" % openid_url)
         return on_failure(request,msg)
 
-    # Add extension args (for things like simple registration)
-    for name, value in extension_args.items():
-        namespace, key = name.split('.', 1)
-        auth_request.addExtensionArg(namespace, key, value)
+    auth_request.addExtension(sreg_request)
     redirect_url = auth_request.redirectURL(trust_root, redirect_to)
     return HttpResponseRedirect(redirect_url)
 
     """
 
     on_failure = signin_failure
-    extension_args = {}
     next = ''
 
 
                 if not next:
                     next = getattr(settings, 'OPENID_REDIRECT_NEXT', '/')
 
-                extension_args['sreg.optional'] = 'email,nickname'
+                sreg_req = sreg.SRegRequest(optional=['nickname','email'])
                 redirect_to = "%s?next=%s" % (
                         get_url_host(request) + reverse('user_complete_signin'), 
                         urllib.urlencode({'next':next}))
                         form_signin.cleaned_data['openid_url'], 
                         redirect_to, 
                         on_failure=signin_failure, 
-                        extension_args=extension_args)
+                        sreg_request=sreg_req)
 
         elif 'blogin' in request.POST.keys():
             # perform normal django authentification