Changeset 783
- Timestamp:
- 13/04/06 17:19:14 (15 years ago)
- Location:
- TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/browseCGI.py
r772 r783 8 8 import ElementTree 9 9 from insecure import * 10 from collections import deque # python 2.4 11 from secure import * 10 12 11 13 def EvaluateCredentials(ac,securityMetadata): … … 13 15 return 1 14 16 17 class RingBuffer(deque): 18 #deque is a python 2.4 class! 19 #credit http://www.onlamp.com/pub/a/python/excerpt/pythonckbk_chap1/index1.html 20 def __init__(self, size_max): 21 deque.__init__(self) 22 self.size_max = size_max 23 def append(self, datum): 24 deque.append(self, datum) 25 if len(self) > self.size_max: 26 self.popleft( ) 27 def tolist(self): 28 return list(self) 29 15 30 class BrowseSession: 16 31 ''' Holds the browse history and contact details for the NDG session manager ''' 17 def __init__(self,cookie ):32 def __init__(self,cookie,url): 18 33 '''Instantiate and get security environment''' 34 # we should have two cookies, the NDG security cookie, and our browse history cookie! 19 35 self.cookie=cookie 20 self.history=[] 36 self.history=RingBuffer(10) 37 self.ndgGate=gateway2NDGsession(cookie,url) 38 self.__loadBrowseHistory() 39 def __loadBrowseHistory(self): 40 ''' get the string of URI values out of the cookie (if it's there)''' 41 try: 42 strHistory=self.cookie['BrowseHistory'].value 43 except: 44 strHistory='[]' 45 for uri in strHistory[1:-1].split(','): self.addToHistory(uri) 21 46 def addToHistory(self,uri): 22 47 ''' Add a URI to the session history''' 23 48 self.history.append(uri) 49 def getHistory(self): 50 ''' Return a list of the items in the history ''' 51 return self.history.tolist() 24 52 def getCredentials(self): 25 53 '''Obtain the attribute certificate from the wallet ''' … … 69 97 self.cookie=self.env.get('HTTP_COOKIE',None) 70 98 71 self.session=BrowseSession(self.cookie )99 self.session=BrowseSession(self.cookie,self.path) 72 100 73 101 #Handle authorisation
Note: See TracChangeset
for help on using the changeset viewer.