Changeset 911
- Timestamp:
- 10/05/06 20:19:31 (15 years ago)
- Location:
- TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/browse.config
r858 r911 3 3 # 4 4 [db] 5 exist: xmldb:exist://glue.badc.rl.ac.uk:8080/exist/xmlrpc 5 exist: xmldb:exist://superglue.badc.rl.ac.uk:8080/exist/xmlrpc 6 #exist: xmldb:exist://glue.badc.rl.ac.uk:8080/exist/xmlrpc 6 7 7 8 [layout] -
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/renderEntity.py
r886 r911 91 91 else: 92 92 html+='<td>public</td><td></td>' 93 html+='<td>%s</td></tr>'%g. binding()93 html+='<td>%s</td></tr>'%g.Aurl 94 94 html+='</tbody></table>' 95 95 return html … … 119 119 if __name__=="__main__": 120 120 from stubB import stubB 121 x=stubB('../../exampleB/methyl.example.xml',xsltMethod='local') 122 html=renderEntity(x) 121 xml=open('../../exampleB/methyl.example.xml').read() 122 x=stubB(xml,makeHTML=renderEntity) 123 html=x.toHTML() 123 124 f=open('output.html','w') 124 125 f.write(html) 125 print x.related126 126 127 127 128 -
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/stubB.py
r886 r911 8 8 from renderEntity import renderEntity 9 9 from Utilities import * 10 from ServiceBinding import * 10 11 11 12 class AccessControl: 13 14 ''' Handle the access control metadata and provide three attributes of the 15 access control: exists (existence), status (modified elsewhere for whether 16 user can access data), and html (a message about the constraints). ''' 17 12 18 def __init__(self,e): 13 self.status=1 14 self.exist=1 15 self.html='constraints' 19 if e is None: 20 self.status=1 21 self.exist=0 22 self.html='' 23 else: 24 self.status=1 25 self.exist=1 26 self.html='constraints' 16 27 17 28 class Name: … … 91 102 self.elem=elem 92 103 self.constraints=AccessControl(elem.find('accessControlPolicy')) 93 def binding(self): 94 #dummy for now 95 return 'Alink' 104 self.binding=ServiceBinding('A',elem.find('dataModelID')) 105 self.Aurl=self.binding.url 96 106 97 107 class DataEntity: … … 139 149 ''' Holds the stub-b document and provides methods which get and manipulate it ''' 140 150 141 def __init__(self,xml,makeHTML=None ):151 def __init__(self,xml,makeHTML=None, ServiceBinding=ServiceBinding): 142 152 143 153 '''Instantiate by parsing an xml document passed in as a string ''' … … 158 168 return 159 169 170 #Note that the root of the ElementTree instance is dgMetadataRecord 171 #so we don't need (or want) that in our xpath expressions. 172 160 173 self.constraints=AccessControl(self.tree.find('dgMetadataRecord/dgMetadataSecurity')) 161 self.related=[]162 163 #note that the root of the ElementTree instance is dgMetadataRecord164 #so we don't need (or want) that in our xpath expressions.165 host='' #bodge166 #this long ifelif sequence needs to go out of moles ...167 174 self.abbreviation=wrapGetText(self.tree,'abbreviation') 175 168 176 elem=self.tree.find('dgDataEntity') 169 177 if elem is not None: … … 171 179 self.type='dgDataEntity' 172 180 self.others=('activity','observationstation','dataproductiontool') 181 173 182 elem=self.tree.find('dgActivity') 174 175 183 if elem is not None: 176 184 self.type='dgActivity' 177 185 self.others=('dgDataEntity','observationstation','dataproductiontool') 186 178 187 elem=self.tree.find('dgDataProductionTool') 179 188 if elem is not None: 180 189 self.type='dgDataProductionTool' 181 190 self.others=('dgDataEntity','observationstation','activity') 191 182 192 elem=self.tree.find('dgObservationStation') 183 193 if elem is not None: … … 186 196 187 197 self.abstract=wrapGetText(self.tree,'dgMetadataDescription/abstract/abstractText') 188 service='cgi/browse.py' 189 self.Burl=self.bind2service(host,service,self.tree.find('dgMetadataID')) 198 199 self.binding=ServiceBinding('B',self.tree.find('dgMetadataID')) 200 self.Burl=self.binding.url 190 201 191 202 # now go get all the related links 192 203 self.related=[] 193 204 for related in self.tree.findall(self.type+'/RelatedDeployment'): 194 205 deployment=['empty',[]] #something should eventually go in the empty slot ... … … 199 210 for subitem in subitems: 200 211 name=wrapGetText(subitem,'name') 201 url=self.bind2service(host,service,subitem.find('dgMetadataID'))202 aa.append([name, url])212 binding=ServiceBinding('B',subitem.find('dgMetadataID')) 213 aa.append([name,binding.url]) 203 214 deployment[1].append([self.labels[item],aa]) 204 215 self.related.append(deployment) 205 206 def bind2service(self,host,service,ndgElement):207 '''Takes the various parts of an id and bind to a service to produce a URL'''208 ### very temporary code ###209 try:210 repID=ndgElement.find('repositoryIdentifier').text211 url='%s/%s?uri=%s/%s'%(host,service,repID,ndgElement.find('localIdentifier').text)212 return url213 except:214 return 'No link'215 216 216 217 def toHTML(self):
Note: See TracChangeset
for help on using the changeset viewer.