Get the current session ID or return a new one
(self)
| 72 | return h.hexdigest() |
| 73 | |
| 74 | def __getsid(self): |
| 75 | """Get the current session ID or return a new one""" |
| 76 | # first, try to load the sid from the GET or POST forms |
| 77 | form = cgi.FieldStorage() |
| 78 | if form.has_key(S_ID): |
| 79 | sid = form[S_ID].value |
| 80 | return sid |
| 81 | |
| 82 | # then try to load the sid from the HTTP cookie |
| 83 | self.cookie = SimpleCookie() |
| 84 | if os.environ.has_key('HTTP_COOKIE'): |
| 85 | self.cookie.load(os.environ['HTTP_COOKIE']) |
| 86 | |
| 87 | if S_ID in self.cookie: |
| 88 | sid = self.cookie[S_ID].value |
| 89 | return sid |
| 90 | else: |
| 91 | raise NoCookiesError("Could not find any cookies") |
| 92 | |
| 93 | # if all else fails, return a new sid |
| 94 | return self.__newsid() |
| 95 | |
| 96 | def getsid(self): |
| 97 | """ |
no test coverage detected