#NEWLINE# @ cache_page ( settings . ITEM_PAGE_CACHE_SECONDS ) #NEWLINE# def gmitem( request , gmbibid ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# bibid = db . get_bibid_from_gmid ( gmbibid ) #NEWLINE# if bibid : #NEWLINE# #INDENT# return redirect ( 'item' , bibid = bibid ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# bib = voyager . get_z3950_bib_data ( gmbibid , 'GM' ) #NEWLINE# if ( not bib ) : #NEWLINE# #INDENT# return render ( request , '404.html' , { #NEWLINE# #INDENT# 'num' : gmbibid , #NEWLINE# 'num_type' : 'BIB ID' , #NEWLINE# #UNINDENT# } , status = 404 ) #NEWLINE# #UNINDENT# bib [ 'openurl' ] = _openurl_dict ( request ) #NEWLINE# bib [ 'citation_json' ] = citation_json ( request ) #NEWLINE# if ( not ( bib [ 'LIBRARY_NAME' ] == settings . PREF_LIB ) ) : #NEWLINE# #INDENT# for alt_bib in bib [ 'BIB_ID_LIST' ] : #NEWLINE# #INDENT# if ( alt_bib [ 'LIBRARY_NAME' ] == settings . PREF_LIB ) : #NEWLINE# #INDENT# return item ( request , alt_bib [ 'BIB_ID' ] ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# holdings = voyager . get_holdings ( bib , 'GM' , False ) #NEWLINE# if holdings : #NEWLINE# #INDENT# holdings = strip_bad_holdings ( holdings ) #NEWLINE# show_wrlc_link = False #NEWLINE# ( ours , theirs , shared ) = splitsort ( callnumsort ( enumsort ( holdings ) ) ) #NEWLINE# holdings = ( ( elecsort ( availsort ( ours ) ) + elecsort ( availsort ( shared ) ) ) + libsort ( elecsort ( availsort ( theirs ) , rev = True ) ) ) #NEWLINE# try : #NEWLINE# #INDENT# linkval = bib . get ( 'LINK' , [ ] ) [ 9 : ] #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# linkval = '' #NEWLINE# #UNINDENT# #UNINDENT# return render ( request , 'item.html' , { #NEWLINE# #INDENT# 'bibid' : show_wrlc_link , #NEWLINE# 'bib' : bib , #NEWLINE# 'holdings' : holdings , #NEWLINE# 'link' : linkval , #NEWLINE# 'show_wrlc_link' : show_wrlc_link , #NEWLINE# 'non_wrlc_item' : True , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# return render ( request , '404.html' , { #NEWLINE# #INDENT# 'num' : gmbibid , #NEWLINE# 'num_type' : 'George Mason BIB ID' , #NEWLINE# #UNINDENT# } , status = 404 ) #NEWLINE# #UNINDENT# except DatabaseError : #NEWLINE# #INDENT# logger . exception ( ( 'unable to render gmbibid: %s' % gmbibid ) ) #NEWLINE# return error500 ( request )