Author: mtredinnick
Date: 2007-05-07 23:13:46 -0500 (Mon, 07 May 2007)
New Revision: 5171

Modified:
   django/trunk/django/core/cache/backends/base.py
   django/trunk/tests/regressiontests/cache/tests.py
Log:
Fixed #4041 -- Added a __contains__ method to cache backends. Thanks, Gary
Wilson and SmileyChris.


Modified: django/trunk/django/core/cache/backends/base.py
===================================================================
--- django/trunk/django/core/cache/backends/base.py     2007-05-08 03:56:44 UTC 
(rev 5170)
+++ django/trunk/django/core/cache/backends/base.py     2007-05-08 04:13:46 UTC 
(rev 5171)
@@ -54,3 +54,6 @@
         Returns True if the key is in the cache and has not expired.
         """
         return self.get(key) is not None
+
+    __contains__ = has_key
+

Modified: django/trunk/tests/regressiontests/cache/tests.py
===================================================================
--- django/trunk/tests/regressiontests/cache/tests.py   2007-05-08 03:56:44 UTC 
(rev 5170)
+++ django/trunk/tests/regressiontests/cache/tests.py   2007-05-08 04:13:46 UTC 
(rev 5171)
@@ -46,6 +46,11 @@
         self.assertEqual(cache.has_key("hello"), True)
         self.assertEqual(cache.has_key("goodbye"), False)
 
+    def test_in(self): 
+        cache.set("hello", "goodbye") 
+        self.assertEqual("hello" in cache, True) 
+        self.assertEqual("goodbye" in cache, False) 
+
     def test_data_types(self):
         # test data types
         stuff = {


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to