Skip to content
This repository has been archived by the owner on Feb 13, 2020. It is now read-only.

Commit

Permalink
Merge pull request #4 from sheilatron/session_set
Browse files Browse the repository at this point in the history
Add a 'set' method to the ZopeCookieSession
  • Loading branch information
tseaver committed Apr 29, 2016
2 parents 96bb506 + ea5ae08 commit 17c201c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions zope2/sessioncookie/__init__.py
Expand Up @@ -47,6 +47,9 @@ def __guarded_setitem__(self, key, value):
def __guarded_delitem__(self, key):
del self[key]

def set(self, key, value):
self[key] = value

InitializeClass(ZopeCookieSession)

return ZopeCookieSession
Expand Down
8 changes: 8 additions & 0 deletions zope2/sessioncookie/tests/test___init__.py
Expand Up @@ -63,6 +63,14 @@ def test_session_class_extras(self):
request._response_callbacks[0](request, response)
self.assertEqual(response.counter, 1)

def test_session_class_set_method(self):
self._setUpUtility()
klass = self._callFUT()
request = _Request()
session = klass(request)
session.set('foo', 'bar')
self.assertEqual(session.__guarded_getitem__('foo'), 'bar')


class SignedSessionCookieCreatedTests(unittest.TestCase):

Expand Down

0 comments on commit 17c201c

Please sign in to comment.