getAuthorities handling exception if no result from Registry platform myslice-1.5
authorLoic Baron <loic.baron@lip6.fr>
Wed, 17 Jun 2015 16:24:00 +0000 (18:24 +0200)
committerLoic Baron <loic.baron@lip6.fr>
Wed, 17 Jun 2015 16:24:00 +0000 (18:24 +0200)
portal/actions.py

index ec4b288..523a9e1 100644 (file)
@@ -84,12 +84,15 @@ def getAuthorities(request, admin = False):
     # XXX theme has to be the same as the root authority 
     result = sfa_client(request,'List',hrn=theme.theme,object_type='authority',platforms=['myslice'],admin=admin)
     authorities = list()
-    for item in result['myslice']:
-        t_hrn = item['hrn'].split('.')
-        if 'name' in item:
-            authorities.append({'authority_hrn':item['hrn'], 'name':item['name'], 'shortname':t_hrn[-1].upper()})    
-        else:
-            authorities.append({'authority_hrn':item['hrn']})    
+    try:
+        for item in result['myslice']:
+            t_hrn = item['hrn'].split('.')
+            if 'name' in item:
+                authorities.append({'authority_hrn':item['hrn'], 'name':item['name'], 'shortname':t_hrn[-1].upper()})    
+            else:
+                authorities.append({'authority_hrn':item['hrn']})    
+    except:
+        logger.error(result)
     return sorted(authorities)