source: TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/renderDiscoveryResponses.py @ 940

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/renderDiscoveryResponses.py@940
Revision 940, 1.2 KB checked in by lawrence, 14 years ago (diff)

Some minor bug fixes in rendering DIFs and stubB

Line 
1from DiscoveryWS import DiscoveryWS
2from DIF import DIF
3from Utilities import cleanup
4
5def render(difSet,summary=0,services=0,spatial=0,temporal=0,linkto='NDG_B_SERVICE'):
6    '''Takes a set of xml DIFS from a discovery search and renders a list of responses as a table,
7    with layout depending on a set of keywords:
8     '''
9    columns=['name','centre']
10    #next three lines not yet used in anger
11    if spatial: columns.insert(-1,'Spatial')
12    if temporal: columns.insert(-1,'Temporal')
13    if services: columns.insert(-1,'Services')
14    html='<table><tbody>'
15    i=1#next three lines not yet used in anger
16    if spatial: columns.insert(-1,'Spatial')
17    if temporal: columns.insert(-1,'Temporal')
18    if services: columns.insert(-1,'Services')
19    for item in difSet:
20        d=DIF(item)
21        bgc={1:'#FFFFFF',-1:'#EEEEEE'}[i]
22        i=-1*i
23        html+='<tr bgcolor=%s><td>%s</td><td>%s</td></tr>'%(
24                bgc,d.name[0:60],d.centre.tohtml())
25    html+='</tbody></table>'
26    return html
27
28if __name__=="__main__":
29    ws=DiscoveryWS()
30    ws.SearchFullText('acsoe')
31    results=ws.GetResults(number=5)
32    difs=[]
33    for result in results:
34        difs.append(cleanup(result))
35    html=render(difs)
36    print html
37    ws.release()
Note: See TracBrowser for help on using the repository browser.