Changeset 8318 for mauRepo


Ignore:
Timestamp:
16/05/12 08:23:05 (8 years ago)
Author:
jhorton
Message:

added exception handling to try and make code a little more resilient

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/MolesManager/trunk/src/MolesManager/views/cedaBrowse.py

    r8316 r8318  
    2929            c['author'] = v.party[0].name 
    3030        if v.role.name == 'cl_pointofcontact': 
    31             c['email_contact_addr'] = v.party[0].contactInfo[0].address.electronicMailAddress[0]; 
    32             c['email_contact_name'] = v.party[0].name; 
     31            try: 
     32                c['email_contact_addr'] = v.party[0].contactInfo[0].address.electronicMailAddress[0]; 
     33                c['email_contact_name'] = v.party[0].name; 
     34            except: 
     35                c['email_contact_addr'] = ""; 
     36                c['email_contact_name'] = ""; 
    3337        if v.role.name == 'cl_publisher': 
    34             c['publisher'] = v.party[0].name 
     38            try: 
     39                c['publisher'] = v.party[0].name 
     40            except: 
     41                c['publisher'] = "" 
    3542        if v.role.name == 'cl_coinvestigator': 
    36             c['co_investigator'] = v.party[0].name; 
     43            try: 
     44                c['co_investigator'] = v.party[0].name; 
     45            except: 
     46                c['co_investigator'] = ""; 
    3747    pubyear = record.resultTime.position.dateTime8601.year; 
    3848    c['citation'] = mark_safe(c['author'] + ";" + c['co_investigator'] + "(" + pubyear + ")" + c['title'] + " " + c['publisher'] + " Available from : <a href=\"http://www.ceda.ac.uk/datacat/" + c['guid'] + "\" target=\"_blank\">http://www.ceda.ac.uk/datacat/" + c['guid'] +"</a>"); 
     
    6474    c['download_link'] = record.result.source[0].linkage 
    6575    c['download_name'] = record.result.source[0].name 
    66     if len(record.permission.useLimitation[0]) != 0: 
    67         p = record.permission.useLimitation[0].split(' http://') 
    68         c['permission'] = mark_safe(p[0] + "  <a href=\"http://" + p[1] + "\" target=\"_blank\">" + p[1] + "<\a>"); 
    69     else: 
     76    try: 
     77        if len(record.permission.useLimitation[0]) != 0: 
     78            p = record.permission.useLimitation[0].split(' http://') 
     79            c['permission'] = mark_safe(p[0] + "  <a href=\"http://" + p[1] + "\" target=\"_blank\">" + p[1] + "<\a>"); 
     80        else: 
     81            c['permission'] = "These data may be open access. Please contact the data centre to enquire about access to these data." 
     82    except: 
    7083        c['permission'] = "These data may be open access. Please contact the data centre to enquire about access to these data." 
    7184    lk = [] 
Note: See TracChangeset for help on using the changeset viewer.