summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2010-10-29 03:49:53 -0400
committerChris McDonough <chrism@plope.com>2010-10-29 03:49:53 -0400
commit66ecc57eb00063edfa01d66f8d6f4495d21d79b5 (patch)
tree9ae8a5745534b7be15e00d9d69eb2030dbc8011c
parent14dc81633acc60ae1e80bdbe7fb8bf8af6d479bb (diff)
downloadpyramid-66ecc57eb00063edfa01d66f8d6f4495d21d79b5.tar.gz
pyramid-66ecc57eb00063edfa01d66f8d6f4495d21d79b5.tar.bz2
pyramid-66ecc57eb00063edfa01d66f8d6f4495d21d79b5.zip
remove modified attr from interface
-rw-r--r--docs/narr/sessions.rst3
-rw-r--r--pyramid/interfaces.py4
-rw-r--r--pyramid/session.py30
-rw-r--r--pyramid/tests/test_session.py17
4 files changed, 11 insertions, 43 deletions
diff --git a/docs/narr/sessions.rst b/docs/narr/sessions.rst
index e460e2d74..56e2ea361 100644
--- a/docs/narr/sessions.rst
+++ b/docs/narr/sessions.rst
@@ -88,9 +88,6 @@ two extra methods.
Extra attributes:
-``modified``
- An integer timestamp indicating the last time the session was modified.
-
``created``
An integer timestamp indicating the time that this session was created.
diff --git a/pyramid/interfaces.py b/pyramid/interfaces.py
index e1d7491b5..56486307a 100644
--- a/pyramid/interfaces.py
+++ b/pyramid/interfaces.py
@@ -392,10 +392,6 @@ class ISession(Interface):
# attributes
created = Attribute('Integer representing Epoch time when created.')
- modified = Attribute(
- 'Integer representing Epoch time of last modification. If the '
- 'session has not yet been modified (it is new), this time will '
- 'be the created time.')
new = Attribute('Boolean attribute. If ``True``, the session is new.')
# special methods
diff --git a/pyramid/session.py b/pyramid/session.py
index 50f071398..158468152 100644
--- a/pyramid/session.py
+++ b/pyramid/session.py
@@ -30,14 +30,6 @@ def manage_accessed(wrapped):
accessed.__doc__ = wrapped.__doc__
return accessed
-def manage_modified(wrapped):
- accessed = manage_accessed(wrapped)
- def modified(session, *arg, **kw):
- session.modified = int(time.time())
- return accessed(session, *arg, **kw)
- modified.__doc__ = accessed.__doc__
- return modified
-
def InsecureCookieSessionFactoryConfig(
secret,
timeout=1200,
@@ -116,20 +108,19 @@ def InsecureCookieSessionFactoryConfig(
def __init__(self, request):
self.request = request
now = time.time()
- created = accessed = modified = now
+ created = accessed = now
new = True
cookieval = request.cookies.get(self._cookie_name)
value = deserialize(cookieval, self._secret)
state = {}
if value is not None:
- accessed, created, modified, state = value
+ accessed, created, state = value
new = False
if now - accessed > self._timeout:
state = {}
self.created = created
self.accessed = accessed
- self.modified = modified
self.new = new
dict.__init__(self, state)
@@ -157,13 +148,13 @@ def InsecureCookieSessionFactoryConfig(
__iter__ = manage_accessed(dict.__iter__)
# modifying dictionary methods
- clear = manage_modified(dict.clear)
- update = manage_modified(dict.update)
- setdefault = manage_modified(dict.setdefault)
- pop = manage_modified(dict.pop)
- popitem = manage_modified(dict.popitem)
- __setitem__ = manage_modified(dict.__setitem__)
- __delitem__ = manage_modified(dict.__delitem__)
+ clear = manage_accessed(dict.clear)
+ update = manage_accessed(dict.update)
+ setdefault = manage_accessed(dict.setdefault)
+ pop = manage_accessed(dict.pop)
+ popitem = manage_accessed(dict.popitem)
+ __setitem__ = manage_accessed(dict.__setitem__)
+ __delitem__ = manage_accessed(dict.__delitem__)
# non-API methods
def _set_cookie(self, response):
@@ -172,8 +163,7 @@ def InsecureCookieSessionFactoryConfig(
if exception is not None: # dont set a cookie during exceptions
return False
cookieval = serialize(
- (self.accessed, self.created, self.modified, dict(self)),
- self._secret
+ (self.accessed, self.created, dict(self)), self._secret
)
if len(cookieval) > 4064:
raise ValueError(
diff --git a/pyramid/tests/test_session.py b/pyramid/tests/test_session.py
index d8c1b2c00..12f70bab9 100644
--- a/pyramid/tests/test_session.py
+++ b/pyramid/tests/test_session.py
@@ -13,7 +13,7 @@ class TestInsecureCookieSession(unittest.TestCase):
def _serialize(self, accessed, state, secret='secret'):
from pyramid.session import serialize
- return serialize((accessed, accessed, accessed, state), secret)
+ return serialize((accessed, accessed, state), secret)
def test_ctor_with_cookie_still_valid(self):
import time
@@ -155,21 +155,6 @@ class Test_manage_accessed(unittest.TestCase):
self.assertEqual(result, None)
self.assertEqual(session.response, response)
-class Test_manage_modified(Test_manage_accessed):
- def _makeOne(self, wrapped):
- from pyramid.session import manage_modified
- return manage_modified(wrapped)
-
- def test_modified_set(self):
- request = testing.DummyRequest()
- session = DummySessionFactory(request)
- session.modified = None
- session.accessed = None
- wrapper = self._makeOne(session.__class__.__setitem__)
- wrapper(session, 'a', 1)
- self.assertNotEqual(session.accessed, None)
- self.assertNotEqual(session.modified, None)
-
def serialize(data, secret):
try:
from hashlib import sha1