]> git.parisson.com Git - django-social-auth.git/commitdiff
Add own tuple_index function to stay compatible with python 2.5
authorJohannes Holmberg <johannes@update.uu.se>
Thu, 16 Feb 2012 12:57:18 +0000 (13:57 +0100)
committerJohannes Holmberg <johannes@update.uu.se>
Thu, 16 Feb 2012 12:57:18 +0000 (13:57 +0100)
social_auth/backends/pipeline/misc.py

index 22b0e19740a866948a0b5cb53dd91f213ad74d85..752b5450959299e4dc9b8918ef1669eb4e209ccf 100644 (file)
@@ -4,18 +4,22 @@ from social_auth.utils import setting
 
 PIPELINE_ENTRY = 'social_auth.backends.pipeline.misc.save_status_to_session'
 
+def tuple_index(t, e):
+    for (i, te) in enumerate(t):
+        if te == e:
+            return i
+    return None
 
 def save_status_to_session(request, auth, *args, **kwargs):
     """Saves current social-auth status to session."""
     next_entry = setting('SOCIAL_AUTH_PIPELINE_RESUME_ENTRY')
 
-    try:
-        if next_entry:
-            idx = PIPELINE.index(next_entry)
-        else:
-            idx = PIPELINE.index(PIPELINE_ENTRY) + 1
-    except ValueError:
-        idx = None
+    if next_entry:
+        idx = tuple_index(PIPELINE, next_entry)
+    else:
+        idx = tuple_index(PIPELINE, PIPELINE_ENTRY)
+        if idx:
+            idx += 1
 
     data = auth.to_session_dict(idx, *args, **kwargs)