diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-07-26 03:58:31 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-07-26 03:58:31 +0000 |
| commit | 6f16b5bad2f714b88639ebb90d30fd6cef686cfc (patch) | |
| tree | c68478fcad80be0388e6512fae263f49dda5c38a /django | |
| parent | f49c5c23f96f11a993036fa10c81b4287327d7ec (diff) | |
Fixed #7967 -- Make sure the __contains__ method in the cache backends call the
right has_key() method for the subclass. Patch from Marty Alchin.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8084 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/cache/backends/base.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/django/core/cache/backends/base.py b/django/core/cache/backends/base.py index ff4223bf86..58e166d655 100644 --- a/django/core/cache/backends/base.py +++ b/django/core/cache/backends/base.py @@ -63,4 +63,11 @@ class BaseCache(object): """ return self.get(key) is not None - __contains__ = has_key + def __contains__(self, key): + """ + Returns True if the key is in the cache and has not expired. + """ + # This is a separate method, rather than just a copy of has_key(), + # so that it always has the same functionality as has_key(), even + # if a subclass overrides it. + return self.has_key(key) |
