Changeset 1286 for TI07-MOLES
- Timestamp:
- 06/07/06 17:02:48 (15 years ago)
- Location:
- TI07-MOLES/trunk/PythonCode/browse/portal/cgi/browse
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TI07-MOLES/trunk/PythonCode/browse/portal/cgi/browse/Utilities.py
r1185 r1286 62 62 def wrapGetText(element,xpathExpression,multiple=0): 63 63 ''' Wraps a call to ET to get a text object in an error handler ''' 64 def none2txt(i): 65 if i is None: return '' 66 return i 64 67 if multiple: 65 68 r=element.findall(xpathExpression) … … 70 73 except: 71 74 rr=['',] 75 rr=map(none2txt,rr) 72 76 if multiple: 73 77 return rr … … 99 103 return ET.fromstring(r) 100 104 105 def EnumerateString(string): 106 ''' Takes a string, and if it's got a number on the end, increments it, 107 otherwise adds a number on the end, used to differentiate strings which 108 would otherwise be identical ''' 109 def addNum(matchObj): 110 s=matchObj.group() 111 return str(int(s)+1) 112 r=re.sub('\d+$',addNum,string) 113 if r==string: r=r+'1' 114 return r 101 115 if __name__=="__main__": 102 x='''<test attr='something'>some content with <a href="target"> display</a> url</test>''' 103 import ElementTree as ET 104 y=ET.fromstring(x) 105 print PrettyPrintHTML(y,['content',]) 106 print PrettyPrint(y) 116 s,t='abc12','def' 117 print s,EnumerateString(s),t,EnumerateString(t) 107 118 -
TI07-MOLES/trunk/PythonCode/browse/portal/cgi/browse/browse.config
r1211 r1286 9 9 jarLoc: returnstubb.jar 10 10 javaBinary: java 11 searchWSDL: http://superglue.badc.rl.ac.uk/exist/services/Discovery?WSDL11 searchWSDL: http://superglue.badc.rl.ac.uk/exist/services/Discovery?WSDL 12 12 13 13 [db] 14 #exist: superglue.badc.rl.ac.uk14 #exist: superglue.badc.rl.ac.uk 15 15 exist: glue.badc.rl.ac.uk 16 16 #exist: gepidae.esc.rl.ac.uk … … 25 25 Xicon: /layout/X.gif 26 26 printer: /layout/printer.gif 27 28 27 ndgLink: http://ndg.nerc.ac.uk/ 29 28 ndgImage: /layout/ndg_logo.gif 30 29 ndgAlt: visit ndg 31 32 30 pageLogo: /layout/browse_header4.gif 33 31 34 32 [security] 35 36 libraryLoc: /home/bnl/sandboxes/ndg/MOLES/browse/portal/cgi/NDG/37 33 localAA: http://glue.badc.rl.ac.uk/attAuthority.wsdl 38 34 localSM: http://glue.badc.rl.ac.uk/sessionMgr.wsdl 35 passwords: /home/bnl/sandboxes/ndg/TI07-MOLES/passwords.txt 39 36 40 37 -
TI07-MOLES/trunk/PythonCode/browse/portal/cgi/browse/browseCGI.py
r1185 r1286 38 38 self.history=RingBuffer(10) 39 39 self.selected=RingBuffer(5) 40 40 self.historyNames=RingBuffer(10) 41 41 self.__load() 42 42 … … 66 66 d={'bh':self.history,'sh':self.selected} 67 67 current=d[tag].tolist() 68 if (uri,name) not in current or ignore: 68 # key the uri's by name ... so we can deal with 69 # duplicate abbreviations. 70 names={} 71 for i in current: names[i[1]]=i[0] 72 if ignore: 69 73 d[tag].append((uri,name)) 74 else: 75 if name in names.keys(): # we might already have it 76 if names[name]!=uri: 77 #it's a duplicate name, but not a duplicate uri 78 d[tag].append((uri,EnumerateString(name))) 79 else: #it's new ... 80 d[tag].append((uri,name)) 70 81 71 82 def addToHistory(self,uri,name,ignore=False): … … 220 231 jar=self.config.get('services','jarLoc') 221 232 javabin=self.config.get('services','javaBinary') 222 xml=insecureGetDoc(self.uri,db=db,format=format,jar=jar,javaBin=javabin) 233 passwordFile=self.config.get('security','passwords','passwords.txt') 234 xml=insecureGetDoc(self.uri,db=db,format=format,jar=jar,javaBin=javabin, 235 passwordFile=passwordFile) 223 236 224 237 #create document instance -
TI07-MOLES/trunk/PythonCode/browse/portal/cgi/browse/insecure.py
r1182 r1286 24 24 25 25 def insecureGetDoc(uri,db='glue.badc.rl.ac.uk',format='NDG-B0', 26 jar='./returnstubb.jar',javaBin='java' ):26 jar='./returnstubb.jar',javaBin='java',passwordFile='passwords.txt'): 27 27 ''' Use Kevin's code to get the document from exist ''' 28 28 #we assume the URI is of the form repository/localid … … 43 43 #this file should exist (for the moment) in the cgi directory ... 44 44 #I know that's not very tidy, but it doesn't matter for the moment ... 45 f=file( 'passwords.txt','r')45 f=file(passwordFile,'r') 46 46 pw={} 47 47 for host in f.readlines():
Note: See TracChangeset
for help on using the changeset viewer.