Skip to content

Commit

Permalink
Raise NotImplementedError for missing backend methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jbittel committed Aug 15, 2016
1 parent 0f035fd commit 20b8e49
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions mama_cas/services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ def _is_allowed(attr, *args):
if getattr(backend, attr)(*args):
return True
except AttributeError:
continue
raise NotImplementedError("%s does not implement %s()" % (backend, attr))
return False


def get_callbacks(service):
for backend in _get_backends():
callbacks = backend.get_callbacks(service)
try:
callbacks = backend.get_callbacks(service)
except AttributeError:
raise NotImplementedError("%s does not implement get_callbacks()" % backend)
if callbacks:
# TODO merge callback dicts?
return callbacks
Expand All @@ -30,7 +33,10 @@ def get_callbacks(service):

def get_logout_url(service):
for backend in _get_backends():
logout_url = backend.get_logout_url(service)
try:
logout_url = backend.get_logout_url(service)
except AttributeError:
raise NotImplementedError("%s does not implement get_logout_url()" % backend)
if logout_url:
return logout_url
return None
Expand Down

0 comments on commit 20b8e49

Please sign in to comment.