Changeset 8321 for mauRepo


Ignore:
Timestamp:
17/05/12 15:27:08 (7 years ago)
Author:
jhorton
Message:

more exception handling

File:
1 edited

Legend:

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

    r8320 r8321  
    1919        guid = Moles3EPB.retrieveGUIDFromInstance(record, request.moles_session) 
    2020        c['guid'] = guid.id 
    21     c['abstract'] = record.inSupportOf.abstract 
     21    try: 
     22        c['abstract'] = record.inSupportOf.abstract 
     23    except: 
     24        c['abstract'] = "" 
    2225    for v in record.identifier: 
    2326        if v.authority.title == 'ceda_title': 
     
    5457            except: 
    5558                c['co_investigator'] = ""; 
    56     pubyear = record.resultTime.position.dateTime8601.year; 
    57     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>"); 
     59    try: 
     60        pubyear = record.resultTime.position.dateTime8601.year; 
     61    except: 
     62        pubyear = "" 
     63    try: 
     64        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>"); 
     65    except: 
     66        c['citation'] = "" 
    5867    try: 
    5968        c['status'] = record.publicationState.value 
     
    99108        c['vertical_extent'] = record.verticalExtent; 
    100109    except: 
    101         c['vertical_extent'] = "" 
     110        c['vertical_extent'] = [""] 
    102111    try: 
    103112        c['resolution'] = record.resolution; 
     
    111120        c['parameters'] = record.parameter; 
    112121    except: 
    113         c['parameters'] = "" 
     122        c['parameters'] = [""] 
    114123    try: 
    115124        c['project_details'] = record.inSupportOf.relatedParty; 
    116125    except: 
    117         c['project_details'] = "" 
     126        c['project_details'] = [""] 
    118127    try: 
    119128        c['procedure'] = record.procedure; 
     
    141150        c['related_data'] = record.relatedObservation; 
    142151    except: 
    143         c['related_data'] = "" 
     152        c['related_data'] = [""] 
    144153    try: 
    145154        c['quality_statement'] = record.resultQuality 
    146155    except: 
    147         c['quality_statement'] = "" 
     156        c['quality_statement'] = [""] 
    148157    try: 
    149158        c['keywords'] = record.keywords[0].keyword[0]; 
     
    167176        c['permission'] = "These data may be open access. Please contact the data centre to enquire about access to these data." 
    168177    lk = [] 
    169     for l in record.result.source: 
    170         ls = l.linkage.strip() 
    171         if len(ls) != 0: 
    172           lk.append(ls) 
    173     c['archive_linkage'] = lk 
     178    try: 
     179        for l in record.result.source: 
     180            ls = l.linkage.strip() 
     181            if len(ls) != 0: 
     182                lk.append(ls) 
     183        c['archive_linkage'] = lk 
     184    except: 
     185        c['archive_linkage'] = [""] 
    174186    try: 
    175187        c['documentation'] = record.documentation 
    176188    except: 
    177         c['documentation'] = "" 
     189        c['documentation'] = [""] 
    178190    return render_to_response('cedaBrowse.html', c) 
    179191 
Note: See TracChangeset for help on using the changeset viewer.