Permalink
Browse files

Don't crash if not organization is defined in the metadata. See bug #…

…931672
  • Loading branch information...
lorenzogil committed Feb 14, 2012
1 parent e1e0007 commit f21f1b38771ac8fb6329e6c270db6ade1405a041
Showing with 16 additions and 13 deletions.
  1. +16 −13 src/saml2/metadata.py
View
@@ -678,31 +678,34 @@ def name(self, entity_id):
""" Find a name from the metadata about this entity id.
The name is either the display name, the name or the url
,in that order, for the organization.
-
+
:param entity_id: The Entity ID
:return: A name
"""
try:
org = self.entity[entity_id]["organization"]
- try:
- name = org.organization_display_name[0]
- except IndexError:
- try:
- name = org.organization_name[0]
+ if org is None:
+ name = ""
+ else:
+ try:
+ name = org.organization_display_name[0]
except IndexError:
try:
- name = org.organization_url[0]
+ name = org.organization_name[0]
except IndexError:
- name = ""
-
- if name:
- name = name.text
+ try:
+ name = org.organization_url[0]
+ except IndexError:
+ name = ""
+
+ if name:
+ name = name.text
except KeyError:
name = ""
-
+
return name
-
+
@keep_updated
def wants(self, entity_id):
try:

0 comments on commit f21f1b3

Please sign in to comment.