Commits

Robert Brewer committed 30b671e

Fix for #640 (cherrypy.session does not implement {{{__contains__}}}).

Comments (0)

Files changed (2)

cherrypy/__init__.py

     
     def __delitem__(self, key):
         del self._get_child()[key]
+    
+    def __contains__(self, key):
+        return key in self._get_child()
 
 
 # Create request and response object (the same objects will be used

cherrypy/test/test_session.py

             return str(c)
         index.exposed = True
         
+        def keyin(self, key):
+            return str(key in cherrypy.session)
+        keyin.exposed = True
+        
         def delete(self):
             cherrypy.session.delete()
             sessions.expire()
         self.getPage('/')
         self.assertBody('1')
         
+        # Test session __contains__
+        self.getPage('/keyin?key=counter', self.cookies)
+        self.assertBody("True")
+        
         # Test session delete
         self.getPage('/delete', self.cookies)
         self.assertBody("done")