Changeset 940
- Timestamp:
- 17/05/06 13:35:11 (15 years ago)
- Location:
- TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/DIF.py
r938 r940 7 7 from People import * 8 8 from ServiceBinding import Service 9 from renderEntity import renderEntity 9 10 10 11 class DIF: … … 12 13 note ... not a complete implementation, currently minimum to 13 14 show a reasonable piece of content ''' 14 def __init__(self,xml ):15 def __init__(self,xml,renderMethod=renderEntity): 15 16 '''Initialise a python dif instance based on an xml document ''' 16 17 self.metadataType='DIF' 17 18 self.elem=ET.fromstring(xml) 19 self.renderMethod=renderMethod 20 self.type='DIF' 18 21 19 22 self.abstract=wrapGetText(self.elem,'Summary') … … 37 40 value=item.text 38 41 if value not in match[level]: match[level].append(value) 42 print self.parameters 39 43 40 44 #load up information about spatial bounding box … … 65 69 self.services.append(s) 66 70 71 def toHTML(self): 72 ''' Use the render method (optionally passed at initialisation, or the 73 default - renderEntity - to get an HTML version of the DIF ''' 74 return self.renderMethod(self) 75 76 77 if __name__=="__main__": 78 79 f=file('../../exampleD/spade.xml') 80 difxml=f.read() 81 D=DIF(cleanup(difxml)) 82 y='''<?xml version="1.0" encoding="UTF-8"?> 83 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 84 <html xmlsns="http://www.w3.org/1999/xhtml" xml:lang="en"> 85 <head> 86 <META http-equiv="Content-Type" content="text/xhtml; charset=iso-8859-1"/> 87 <title>%s</title> 88 <LINK media="all, screen" href="../layout/style.css" type="text/css" rel="stylesheet"/> 89 </head> '''%D.name+D.toHTML() 90 f.close() 91 f=file('output.html','wb') 92 f.write(y) 93 94 67 95 68 96 -
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/People.py
r938 r940 29 29 ... for presentation we figure further org contacts can be found by following the link which ought to exist) ''' 30 30 self.data={'personName':'','personEmail':'','personPhone':'','orgURL':'','orgName':'','searchlink':''} 31 def to html(self,prefix=''):31 def toHTML(self,prefix=''): 32 32 if self.elem is None: return '' 33 33 def makelink(r,n): 34 34 if r!='': 35 return '<a href="%s %>%s</a>'%(a,b)35 return '<a href="%s">%s</a>'%(r,n) 36 36 else: return n 37 37 html='<p>'+prefix … … 55 55 ''' Instantiate a MOLES contact element ''' 56 56 self.elem=element 57 contact.__init__(self) 57 58 if self.elem is None: return 58 contact.__init__(self) 59 self.data['personName']=Name(self.elem.find('dgRoleHolder/dgPerson/name')) 59 self.data['personName']=Name(self.elem.find('dgRoleHolder/dgPerson/name')) 60 60 if ctype=='organisation': 61 61 base='dgRoleHolder/dgOrganisation/' … … 70 70 def __init__(self,elem,ctype='centre'): 71 71 self.elem=elem 72 contact.__init__(self) 72 73 if self.elem is None: return 73 contact.__init__(self)74 74 if ctype=='centre': 75 75 self.data['orgName']=wrapGetText(self.elem,'Data_Center_Name/Short_Name') -
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/renderDiscoveryResponses.py
r938 r940 3 3 from Utilities import cleanup 4 4 5 def 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 ''' 5 def 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 ''' 7 9 columns=['name','centre'] 8 10 #next three lines not yet used in anger … … 11 13 if services: columns.insert(-1,'Services') 12 14 html='<table><tbody>' 13 i=1 14 for item in results: 15 d=DIF(cleanup(item)) 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) 16 21 bgc={1:'#FFFFFF',-1:'#EEEEEE'}[i] 17 22 i=-1*i 18 23 html+='<tr bgcolor=%s><td>%s</td><td>%s</td></tr>'%( 19 bgc,d.name ,d.centre)24 bgc,d.name[0:60],d.centre.tohtml()) 20 25 html+='</tbody></table>' 21 26 return html … … 25 30 ws.SearchFullText('acsoe') 26 31 results=ws.GetResults(number=5) 27 html=render(results) 32 difs=[] 33 for result in results: 34 difs.append(cleanup(result)) 35 html=render(difs) 28 36 print html 29 37 ws.release() -
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/renderEntity.py
r938 r940 11 11 if entity is None: return '' 12 12 13 try:14 15 except:16 contentHTML=''13 #try: 14 contentHTML=renderContent(entity) 15 #except: 16 # contentHTML='' 17 17 18 18 if entity.metadataType is 'stubB': … … 42 42 '''Parse the entity for content information ''' 43 43 44 if entity.constraints.exists: 45 html='<p>Access Control: %s</p>'%entity.constraints.html 46 else: 47 html='' 44 html='' 45 try: 46 if entity.constraints.exists: 47 html='<p>Access Control: %s</p>'%entity.constraints.html 48 except: pass 48 49 49 50 html+=''' … … 55 56 </tr>''' 56 57 57 58 for item in entity.parameters: 58 59 html+=''' 59 60 <tr><td class="line"><b>Parameter</b><br/></td> … … 103 104 return html 104 105 else: return '' 106 107 def renderDataLinks(entity): 108 return 'some data link stuff' 105 109 106 110 def renderRelated(entity):
Note: See TracChangeset
for help on using the changeset viewer.