mirror of
https://github.com/django/django.git
synced 2025-10-25 06:36:07 +00:00
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
This commit is contained in:
9
django/core/cache/backends/base.py
vendored
9
django/core/cache/backends/base.py
vendored
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user