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

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

First code to support a GUI for python based searching through the
discovery WS interface. Includes some refactoring of the browse code
to support multiple entities (i.e. DIF etc). (NB: browse still
wont work properly until we get the security stuff working ok).

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