From 1e6dca16eb5d354614854231a7a3497fc68ac2c1 Mon Sep 17 00:00:00 2001 From: Allan Saddi Date: Sat, 2 Dec 2006 19:40:02 +0000 Subject: Add forceCookieOutput attribute to SessionService to force Set-Cookie output for the current request. --- ChangeLog | 5 +++++ flup/middleware/session.py | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 87c9a7a..90911f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-12-02 Allan Saddi + + * Add forceCookieOutput attribute to SessionService to + force Set-Cookie output for the current request. + 2006-12-01 Allan Saddi * Update setup script. diff --git a/flup/middleware/session.py b/flup/middleware/session.py index 9656136..c4396fe 100644 --- a/flup/middleware/session.py +++ b/flup/middleware/session.py @@ -540,6 +540,8 @@ class SessionService(object): necessary). service.cookieAttributes - Dictionary of additional RFC2109 attributes to be added to the generated cookie. + service.forceCookieOutput - Normally False. Set to True to force + output of the Set-Cookie header during this request. """ _expiredSessionIdentifier = 'expired session' @@ -552,6 +554,7 @@ class SessionService(object): self._cookieName = cookieName self._cookieExpiration = cookieExpiration self.cookieAttributes = dict(cookieAttributes) + self.forceCookieOutput = False self._fieldName = fieldName self._session = None @@ -615,7 +618,8 @@ class SessionService(object): def addCookie(self, headers): """Adds Set-Cookie header if needed.""" - if not self.encodesSessionInURL and self._shouldAddCookie(): + if not self.encodesSessionInURL and \ + (self._shouldAddCookie() or self.forceCookieOutput): if self._session is not None: sessId = self._sessionIdentifier() expireCookie = not self._session.isValid -- cgit v1.2.1