Changeset 800 for TI07-MOLES
- Timestamp:
- 19/04/06 21:08:42 (15 years ago)
- Location:
- TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/browseCGI.py
r789 r800 6 6 #import cgitb;ctitb.enable() 7 7 import os 8 import ElementTree 8 import ElementTree as ET 9 9 from insecure import * 10 10 from collections import deque # python 2.4 11 11 from secure import * 12 from stubB import * 12 13 13 14 def EvaluateCredentials(ac,securityMetadata): … … 37 38 self.ndgGate=gateway2NDGsession(cookie,url) 38 39 self.__loadBrowseHistory() 39 self.addToHistory(url)40 40 self.writeCookie() 41 41 def __loadBrowseHistory(self): … … 45 45 except: 46 46 strHistory='[]' 47 for uri in strHistory[1:-1].split(','): self.addToHistory(uri) 48 def addToHistory(self,uri): 47 #this will definitely break when we have a real cookie ... 48 if strHistory !='[]': 49 for uri,name in strHistory[1:-1].split(','): self.addToHistory(uri,name) 50 def addToHistory(self,uri,name): 49 51 ''' Add a URI to the session history''' 50 self.history.append( uri)52 self.history.append((uri,name)) 51 53 def getHistory(self): 52 54 ''' Return a list of the items in the history ''' … … 58 60 ''' Write out the current cookie ''' 59 61 pass 60 61 class StubB:62 ''' Holds the stub-b document and provides methods which get and manipulate it '''63 64 def __init__(self,uri,xsltMethod='JavaXalan'):65 '''Instantiate by getting URI from exist database'''66 #try:67 self.xml=insecureGetDoc(uri)68 #self.xml=uri69 #except:70 # raise 'NotFound'71 self.xsltMethod=xsltMethod72 73 def getSecurityDetails(self):74 '''Obtain the roles and attribute authority address'''75 #issue an xquery on the stub-b76 #parse for roles77 #parse for AA WSDL78 #tree=ElementTree.fromstring(self.xml)79 #sec=tree.findall('//ndgSecurity')80 roles=[]81 AAaddress=''82 return roles, AAaddress83 84 def toHTML(self):85 x=doXSLT(self.xml,xsltMethod=self.xsltMethod)86 #return '<p>%s</p>'%x87 return x88 62 89 63 class CGIcontroller: … … 102 76 self.cookie=self.env.get('HTTP_COOKIE',None) 103 77 104 self.session=BrowseSession(self.cookie,self.path) 78 #this will do for the moment, although I'd rather the whole 79 #URI was self consistent ... 80 81 if self.FieldStorage.has_key('uri'): 82 self.uri=self.FieldStorage['uri'].value 83 else: 84 return self.error('No valid URI') 85 self.session=BrowseSession(self.cookie,self.uri) 105 86 106 87 #Handle authorisation 107 88 self.ac=self.session.getCredentials() 108 89 109 #this will do for the moment, although I'd rather the whole110 #URI was self consistent ...111 if self.FieldStorage.has_key('uri'):112 self.uri=self.FieldStorage['uri'].value113 else:114 return self.error('No valid URI')115 90 try: 116 self.b=StubB(self.uri) 91 self.b=stubB(self.uri) 92 self.session.addToHistory(self.b.name,self.b.Burl) 117 93 except 'NotFound': 118 94 return self.error('URI cannot be retrieved from DataBase') … … 124 100 historyHTML='<p>' 125 101 for item in self.session.getHistory(): 126 historyHTML+= item+'</br>'102 historyHTML+='<a href="%s">%s</a></br>'%item 127 103 historyHTML+='</p>' 128 104 return parsedHTML.replace('PutNDGBrowseHistoryHere',historyHTML) -
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/insecure.py
r772 r800 37 37 repPath,localID=uri.split('/') 38 38 except: 39 return 'Invalid URI' 39 return None 40 returnMolesJar=jarLoc(jar) 41 cmd='java -jar %s %s %s xmldb:exist://glue.badc.rl.ac.uk:8080/exist/xmlrpc'%( 42 returnMolesJar,repPath,localID) 43 status,result=osCommand(cmd) 44 if status: 45 return None 40 46 else: 41 returnMolesJar=jarLoc(jar)42 cmd='java -jar %s %s %s xmldb:exist://glue.badc.rl.ac.uk:8080/exist/xmlrpc'%(43 returnMolesJar,repPath,localID)44 status,result=osCommand(cmd)45 47 return result 46 48
Note: See TracChangeset
for help on using the changeset viewer.