Changeset 996
- Timestamp:
- 24/05/06 10:18:57 (15 years ago)
- Location:
- TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi
- Files:
-
- 4 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/DIF.py
r963 r996 41 41 value=item.text 42 42 if value not in match[level]: match[level].append(value) 43 print self.parameters 44 43 45 44 #load up information about spatial bounding box 46 45 self.bbox=Bounding(self.elem,entity='DIF') -
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/ETxmlView.py
r976 r996 7 7 8 8 import ElementTree as ET 9 import re 9 10 10 11 def et2text(elem,indent='',html=0,space=' '): -
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/browseCGI.py
r991 r996 15 15 from renderEntity import renderEntity 16 16 from renderPage import renderPage 17 from renderDiscoverySet import renderDiscoverySet 17 18 from Utilities import * 18 19 from ETxmlView import * 20 from DiscoveryWS import * 19 21 20 22 import Cookie … … 25 27 to work with the discovery portal as well ''' 26 28 27 def __init__(self,cookie, url,config):29 def __init__(self,cookie,config): 28 30 29 31 '''Instantiate with an unsecured browse session (security only … … 34 36 self.history=RingBuffer(10) 35 37 self.__loadBrowseHistory() 36 self.url=url37 38 38 39 def __toXML(self): … … 96 97 ''' This method actually responds to the user''' 97 98 98 #Instantiate the Session Environment 99 self.ViewTextOnly,self.ViewXML=0,0 100 101 #Instantiate the Session Environment 99 102 self.cookie=self.env.get('HTTP_COOKIE',None) 100 103 self.session=BrowseSession(self.cookie,self.config) 104 if self.config.logfile is not None: self.config.log(self.cookie) 105 101 106 #this will do for the moment, although I'd rather the whole 102 107 #URI was self consistent ... 103 108 109 #use name as an error return as well in the following calls ... 104 110 if self.FieldStorage.has_key('uri'): 105 111 self.uri=self.FieldStorage['uri'].value 106 else: 112 content,name=self.__browse() 113 elif self.FieldStorage.has_key('search'): 114 self.searchType=self.FieldStorage['search'].value 115 content,name=self.__search() 116 else: 107 117 self.response.content=self.error('No valid URI') 108 118 return self.response 109 110 self.ViewTextOnly,self.ViewXML=0,0 119 120 if not self.ViewTextOnly and name !=0: 121 historyHTML='<p>' 122 for item in self.session.getHistory(): 123 historyHTML+='<a href="%s">%s</a><br/>'%item 124 historyHTML+='</p>' 125 self.response.content=renderPage( 126 content,historyHTML,historyHTML,name,self.config) 127 else: 128 self.response.content=content 129 return self.response 130 131 def __browse(self): 132 ''' Handle orthodox browsing ''' 133 111 134 if self.FieldStorage.has_key('text'): 112 135 self.ViewTextOnly=1 … … 116 139 if self.FieldStorage.has_key('ndgSec'): 117 140 pass 118 119 self.session=BrowseSession(self.cookie,self.uri,self.config) 120 121 if self.config.logfile is not None: self.config.log(self.cookie) 122 141 123 142 #this is where we invoke NDG security setup 124 143 self.makeGateway() … … 133 152 if self.b.xml is None: 134 153 content=self.error('Unable to obtain stub-B from database') 154 return content,0 135 155 else: 136 156 self.session.addToHistory(self.b.Burl,self.b.abbreviation) … … 146 166 access=1 147 167 if access: 168 name=self.b.name 148 169 if self.ViewTextOnly: 149 170 self.response.contentType='text/plain' … … 154 175 content=self.b.toHTML() 155 176 else: 177 name='NDG Browse' 156 178 content=result 157 158 if not self.ViewTextOnly: 159 historyHTML='<p>' 160 for item in self.session.getHistory(): 161 historyHTML+='<a href="%s">%s</a><br/>'%item 162 historyHTML+='</p>' 163 self.response.content=renderPage( 164 content,historyHTML,historyHTML,self.b.name,self.config) 165 else: 166 self.response.content=content 167 168 return self.response 169 179 180 return content,name 181 182 def __search(self): 183 ''' Handle simple searching within the context of the browse ''' 184 if self.FieldStorage.has_key('SEARCHSTRING'): 185 searchString=self.FieldStorage['SEARCHSTRING'].value 186 ws=DiscoveryWS() 187 ws.SearchFullText(searchString) 188 results=ws.GetResults(number=5) 189 difs=[] 190 for result in results: 191 difs.append(xmlCleanup(result)) 192 html=renderDiscoverySet(difs,summary=1,spatial=1,temporal=1) 193 title='Search for '+searchString 194 return html,title 195 else: 196 return self.error('No valid search optoin'),0 197 170 198 def error(self,message): 171 199 ''' Construct a nice formal response, but don't throw a 404 ... ''' -
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/renderDiscoverySet.py
r994 r996 18 18 h='<tr bgcolor="%s">'%bgcolor 19 19 for item in rowList: 20 print item21 20 if type(item)==type((1,2)): 22 21 h+='<td colspan="%s">%s</td>'%(item[1],item[0]) … … 78 77 from ETxmlView import xmlCleanup 79 78 ws=DiscoveryWS() 80 ws.SearchFullText(' acsoe')79 ws.SearchFullText('humidity') 81 80 results=ws.GetResults(number=5) 82 81 difs=[] 82 g=file('log.xml','w') 83 83 for result in results: 84 g.write(xmlCleanup(result)+'\n') 84 85 difs.append(xmlCleanup(result)) 85 86 html=renderDiscoverySet(difs,summary=1,spatial=1,temporal=1) -
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/renderPage.py
r993 r996 17 17 #set up search box form ... 18 18 searchBox=''' 19 <FORM NAME="SEARCH" ACTION=" http://ndg.nerc.ac.uk/discovery/Task" METHOD="POST>19 <FORM NAME="SEARCH" ACTION="browse.py" METHOD="POST> 20 20 <INPUT TYPE="HIDDEN" NAME="task" VALUE="discovery"/> 21 21 <INPUT TYPE="HIDDEN" NAME="dispSum" VALUE="false"/>
Note: See TracChangeset
for help on using the changeset viewer.