summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Saddi <allan@saddi.com>2006-12-02 19:40:02 +0000
committerAllan Saddi <allan@saddi.com>2006-12-02 19:40:02 +0000
commit1e6dca16eb5d354614854231a7a3497fc68ac2c1 (patch)
treedcfda2f7671ca54afa9399074b7b80bb4235a7cd
parenta1b183f0db5b65c327a0e41f2cb3f18ebf76bf5e (diff)
downloadflup-1e6dca16eb5d354614854231a7a3497fc68ac2c1.tar.gz
Add forceCookieOutput attribute to SessionService to
force Set-Cookie output for the current request.
-rw-r--r--ChangeLog5
-rw-r--r--flup/middleware/session.py6
2 files changed, 10 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 87c9a7a..90911f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-12-02 Allan Saddi <asaddi@sahara.flup.org>
+
+ * Add forceCookieOutput attribute to SessionService to
+ force Set-Cookie output for the current request.
+
2006-12-01 Allan Saddi <asaddi@europa.saddi.net>
* 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