Skip to content

Commit

Permalink
Add own tuple_index function to stay compatible with python 2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Jolmberg committed Feb 16, 2012
1 parent 525c8dc commit 7e6af72
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions social_auth/backends/pipeline/misc.py
Expand Up @@ -4,18 +4,22 @@

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)

Expand Down

0 comments on commit 7e6af72

Please sign in to comment.