[Zope3-checkins] CVS: Zope3/src/zope/app/services - session.py:1.7
Steve Alexander
steve@cat-box.net
Sun, 2 Mar 2003 13:09:32 -0500
Update of /cvs-repository/Zope3/src/zope/app/services
In directory cvs.zope.org:/tmp/cvs-serv8037/src/zope/app/services
Modified Files:
session.py
Log Message:
A keyword argument value of None when setting a cookie causes that
keyword argument to be ignored. This is useful when you have a case
where you sometimes want to set that value, and sometimes do not.
Made the lifespan of cookies in the session cookie service come from
an instance variable, rather than being hard-coded.
=== Zope3/src/zope/app/services/session.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/services/session.py:1.6 Fri Feb 28 09:19:39 2003
+++ Zope3/src/zope/app/services/session.py Sun Mar 2 13:09:01 2003
@@ -49,6 +49,7 @@
self.dataManagers = PersistentDict()
self.namespace = "zope3-cs-%x" % (int(time.time()) - 1000000000)
self.secret = "%.20f" % random.random()
+ self.cookieLifeSeconds = 1800
def generateUniqueId(self):
"""Generate a new, random, unique id."""
@@ -90,10 +91,14 @@
# have to be altered to take virtual hosting into account.
# Seeing as this service instance has a unique namespace for its
# cookie, using ApplicationURL shouldn't be a problem.
+ if self.cookieLifeSeconds:
+ expires = build_http_date(time.time() + self.cookieLifeSeconds)
+ else:
+ expires = None
request.response.setCookie(
self.namespace,
id,
- expires=build_http_date(time.time() + 1800),
+ expires=expires,
path=request.getApplicationURL(path_only=True)
)
@@ -123,7 +128,6 @@
def unregisterDataManager(self, name):
del self.dataManagers[name]
-
def getSessionDataObject(context, request, name):