Changeset 976
- Timestamp:
- 22/05/06 16:40:48 (15 years ago)
- Location:
- TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/ETxmlView.py
r963 r976 23 23 if children: 24 24 for item in elem: 25 result+='\n'+ PrettyPrint(item,indent=indent+space)25 result+='\n'+et2text(item,indent=indent+space) 26 26 result+='\n%s%s</%s>'%(indent,estrip(item.tail),elem.tag) 27 27 else: … … 58 58 if children: 59 59 for item in elem: 60 result+= PrettyPrintHTML(item,matchList)60 result+=et2html(item,matchList) 61 61 result+='%s%s/%s%s'%(match(item.tail),lt,span(elem.tag,'xmlElemTag'),gt) 62 62 else: -
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/browse.config
r911 r976 3 3 # 4 4 [db] 5 exist: xmldb:exist://superglue.badc.rl.ac.uk:8080/exist/xmlrpc 6 #exist: xmldb:exist://glue.badc.rl.ac.uk:8080/exist/xmlrpc 5 #exist: superglue.badc.rl.ac.uk 6 #exist: glue.badc.rl.ac.uk 7 exist: gepidae.esc.rl.ac.uk 7 8 8 9 [layout] -
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/browseCGI.py
r963 r976 16 16 from renderPage import renderPage 17 17 from Utilities import * 18 from ETxmlView import * 18 19 19 20 import Cookie … … 103 104 self.uri=self.FieldStorage['uri'].value 104 105 else: 105 return self.error('No valid URI') 106 self.response.content=self.error('No valid URI') 107 return self.response 106 108 107 109 self.ViewTextOnly,self.ViewXML=0,0 … … 110 112 elif self.FieldStorage.has_key('xml'): 111 113 self.ViewXML=1 114 112 115 113 116 self.session=BrowseSession(self.cookie,self.uri,self.config) 114 117 if self.config.logfile is not None: self.config.log(self.cookie) 115 116 #Handle authorisation117 self.ac=self.session.getCredentials()118 118 119 119 #get the xml document … … 136 136 if access: 137 137 if self.ViewTextOnly: 138 self.response.contentType='text/ text'138 self.response.contentType='text/plain' 139 139 content=et2text(self.b.tree) 140 elif self.ViewXML=1: 141 content=et2HTML(self.b.tree) 140 elif self.ViewXML==1: 141 #self.response.contentType='text/html' 142 content=et2html(self.b.tree) 142 143 else: 143 144 content=self.b.toHTML() … … 152 153 self.response.content=renderPage( 153 154 content,historyHTML,historyHTML,self.b.name,self.config) 155 else: 156 self.response.content=content 154 157 155 158 return self.response -
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/insecure.py
r857 r976 31 31 return 0,s 32 32 33 def insecureGetDoc(uri,db=' xmldb:exist://glue.badc.rl.ac.uk:8080/exist/xmlrpc', jar='./returnmoles.jar'):33 def insecureGetDoc(uri,db='glue.badc.rl.ac.uk', jar='./returnstubb.jar'): 34 34 ''' Use Kevin's code to get the document from exist ''' 35 35 #we assume the URI is of the form repository/localid 36 36 #we don't use os.path.split, because this is os indpendent. 37 edb='xmldb:exist://%s:8080/exist/xmlrpc'%db 37 38 try: 38 39 repPath,localID=uri.split('/') 39 40 except: 40 41 return None 41 returnMolesJar=jarLoc(jar) 42 cmd='java -jar %s %s %s %s'%( 43 returnMolesJar,repPath,localID, db) 44 status,result=commands.getstatusoutput(cmd)#osCommand(cmd) 42 #we can hash all this up properly later ... 43 #this file should exist (for the moment) in the cgi directory ... 44 #I know that's not very tidy, but it doesn't matter for the moment ... 45 f=file('passwords.txt','r') 46 pw={} 47 for host in f.readlines(): 48 h=host.strip().split(' ') 49 pw[h[0]]=h[1],h[2] 50 #try: 51 returnMolesJar=jarLoc(jar) 52 cmd='java -jar %s repositoryID %s localID %s repository %s user %s userpw %s '%( 53 returnMolesJar,repPath,localID, edb, pw[db][0], pw[db][1]) 54 status,result=commands.getstatusoutput(cmd) 55 #except: 56 # return None 45 57 if status: 46 58 return None … … 76 88 if __name__=="__main__": 77 89 #d= insecureGetDoc('badc.nerc.ac.uk/dataent13',jar='../returnmoles.jar') 78 d= insecureGetDoc('badc.nerc.ac.uk/activity3',jar='../returnmoles.jar') 90 d= insecureGetDoc('badc.nerc.ac.uk/dataent1',db='gepidae.esc.rl.ac.uk', 91 jar='../returnstubb.jar') 79 92 print d 80 93 #print d -
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/renderEntity.py
r940 r976 12 12 13 13 #try: 14 contentHTML=renderContent(entity)14 15 15 #except: 16 16 # contentHTML='' … … 20 20 else: 21 21 relatedHTML='' 22 22 23 23 24 if entity.type=='dgDataEntity': 25 contentHTML=renderDataContent(entity) 24 26 relatedHTML=renderGranules(entity)+relatedHTML 25 27 elif entity.type=='DIF': 28 contentHTML=renderDataContent(entity) 26 29 relatedHTML=renderDataLinks(entity)+relatedHTML 30 else: 31 contentHTML='' 27 32 28 33 html=''' … … 39 44 return html 40 45 41 def render Content(entity):42 '''Parse theentity for content information '''46 def renderDataContent(entity): 47 '''Parse a data entity for content information ''' 43 48 44 49 html='' … … 56 61 </tr>''' 57 62 58 for item in entity.parameters: 63 64 try: 65 #currently all entities are parsed for these ... 66 for item in entity.parameters: 59 67 html+=''' 60 68 <tr><td class="line"><b>Parameter</b><br/></td> 61 69 <td class="line">%s</td></tr>'''%item 62 70 63 71 html+=''' 64 72 <tr><td class="line"><b>Spatial Coverage</b><br/></td> 65 73 <td class="line">%s</td></tr>'''%entity.bbox.toHTML() 66 74 67 75 html+=''' 68 76 <tr><td class="line"><b>Temporal Coverage</b><br/></td> 69 77 <td class="line">%s</td></tr>'''%entity.timeCoverage 70 78 79 except: pass 80 71 81 html+=''' 72 82 <tr><td class="line"><b>Data Curator</b><br/></td> -
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/stubB.py
r949 r976 20 20 self.binding=ServiceBinding('A',elem.find('dataModelID')) 21 21 self.Aurl=self.binding.url 22 23 24 class ObservationStation: 25 def __init__(self,e): 26 self.e=e 27 if e is None: return 28 class DataProductionTool: 29 def __init__(self,e): 30 self.e=e 31 if e is None: return 32 class Activity: 33 def __init__(self,e): 34 self.e=e 35 if e is None: return 36 class Deployment: 37 def __init__(self,e): 38 self.e=e 39 if e is None: return 22 40 23 41 class DataEntity: … … 63 81 64 82 65 class stubB(DataEntity ):83 class stubB(DataEntity,Deployment,ObservationStation,DataProductionTool,Activity): 66 84 67 85 ''' Holds the stub-b document and provides methods which get and manipulate it '''
Note: See TracChangeset
for help on using the changeset viewer.