Replaced `has_key()` calls with `in` to ease Python 3 port. Thanks, Martin von Löwis.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16740 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
7deb25b8dd
commit
fb590bfa9b
|
@ -86,7 +86,7 @@ class CalendarPlugin(DatabrowsePlugin):
|
||||||
if url is None:
|
if url is None:
|
||||||
return self.homepage_view(request)
|
return self.homepage_view(request)
|
||||||
url_bits = url.split('/')
|
url_bits = url.split('/')
|
||||||
if self.fields.has_key(url_bits[0]):
|
if url_bits[0] in self.fields:
|
||||||
return self.calendar_view(request, self.fields[url_bits[0]], *url_bits[1:])
|
return self.calendar_view(request, self.fields[url_bits[0]], *url_bits[1:])
|
||||||
|
|
||||||
raise http.Http404('The requested page does not exist.')
|
raise http.Http404('The requested page does not exist.')
|
||||||
|
|
|
@ -53,7 +53,7 @@ class FieldChoicePlugin(DatabrowsePlugin):
|
||||||
if url is None:
|
if url is None:
|
||||||
return self.homepage_view(request)
|
return self.homepage_view(request)
|
||||||
url_bits = url.split('/', 1)
|
url_bits = url.split('/', 1)
|
||||||
if self.fields.has_key(url_bits[0]):
|
if url_bits[0] in self.fields:
|
||||||
return self.field_view(request, self.fields[url_bits[0]], *url_bits[1:])
|
return self.field_view(request, self.fields[url_bits[0]], *url_bits[1:])
|
||||||
|
|
||||||
raise http.Http404('The requested page does not exist.')
|
raise http.Http404('The requested page does not exist.')
|
||||||
|
|
|
@ -113,7 +113,7 @@ class SessionBase(object):
|
||||||
self.modified = True
|
self.modified = True
|
||||||
|
|
||||||
def has_key(self, key):
|
def has_key(self, key):
|
||||||
return self._session.has_key(key)
|
return key in self._session
|
||||||
|
|
||||||
def values(self):
|
def values(self):
|
||||||
return self._session.values()
|
return self._session.values()
|
||||||
|
|
|
@ -43,9 +43,7 @@ class SessionStore(SessionBase):
|
||||||
raise CreateError
|
raise CreateError
|
||||||
|
|
||||||
def exists(self, session_key):
|
def exists(self, session_key):
|
||||||
if self._cache.has_key(session_key):
|
return session_key in self._cache
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def delete(self, session_key=None):
|
def delete(self, session_key=None):
|
||||||
if session_key is None:
|
if session_key is None:
|
||||||
|
|
|
@ -131,9 +131,7 @@ class SessionStore(SessionBase):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def exists(self, session_key):
|
def exists(self, session_key):
|
||||||
if os.path.exists(self._key_to_file(session_key)):
|
return os.path.exists(self._key_to_file(session_key))
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def delete(self, session_key=None):
|
def delete(self, session_key=None):
|
||||||
if session_key is None:
|
if session_key is None:
|
||||||
|
|
|
@ -80,7 +80,7 @@ class SessionTestsMixin(object):
|
||||||
self.session['some key'] = 1
|
self.session['some key'] = 1
|
||||||
self.session.modified = False
|
self.session.modified = False
|
||||||
self.session.accessed = False
|
self.session.accessed = False
|
||||||
self.assertTrue(self.session.has_key('some key'))
|
self.assertTrue('some key' in self.session)
|
||||||
self.assertTrue(self.session.accessed)
|
self.assertTrue(self.session.accessed)
|
||||||
self.assertFalse(self.session.modified)
|
self.assertFalse(self.session.modified)
|
||||||
|
|
||||||
|
|
|
@ -283,7 +283,7 @@ class ManagementUtility(object):
|
||||||
and formatted as potential completion suggestions.
|
and formatted as potential completion suggestions.
|
||||||
"""
|
"""
|
||||||
# Don't complete if user hasn't sourced bash_completion file.
|
# Don't complete if user hasn't sourced bash_completion file.
|
||||||
if not os.environ.has_key('DJANGO_AUTO_COMPLETE'):
|
if 'DJANGO_AUTO_COMPLETE' not in os.environ:
|
||||||
return
|
return
|
||||||
|
|
||||||
cwords = os.environ['COMP_WORDS'].split()[1:]
|
cwords = os.environ['COMP_WORDS'].split()[1:]
|
||||||
|
|
|
@ -23,7 +23,7 @@ except ImportError:
|
||||||
import Cookie
|
import Cookie
|
||||||
# httponly support exists in Python 2.6's Cookie library,
|
# httponly support exists in Python 2.6's Cookie library,
|
||||||
# but not in Python 2.5.
|
# but not in Python 2.5.
|
||||||
_morsel_supports_httponly = Cookie.Morsel._reserved.has_key('httponly')
|
_morsel_supports_httponly = 'httponly' in Cookie.Morsel._reserved
|
||||||
# Some versions of Python 2.7 and later won't need this encoding bug fix:
|
# Some versions of Python 2.7 and later won't need this encoding bug fix:
|
||||||
_cookie_encodes_correctly = Cookie.SimpleCookie().value_encode(';') == (';', '"\\073"')
|
_cookie_encodes_correctly = Cookie.SimpleCookie().value_encode(';') == (';', '"\\073"')
|
||||||
# See ticket #13007, http://bugs.python.org/issue2193 and http://trac.edgewall.org/ticket/2256
|
# See ticket #13007, http://bugs.python.org/issue2193 and http://trac.edgewall.org/ticket/2256
|
||||||
|
@ -591,7 +591,7 @@ class HttpResponse(object):
|
||||||
|
|
||||||
def has_header(self, header):
|
def has_header(self, header):
|
||||||
"""Case-insensitive check for a header."""
|
"""Case-insensitive check for a header."""
|
||||||
return self._headers.has_key(header.lower())
|
return header.lower() in self._headers
|
||||||
|
|
||||||
__contains__ = has_header
|
__contains__ = has_header
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ class SafeExceptionReporterFilter(ExceptionReporterFilter):
|
||||||
else:
|
else:
|
||||||
# Cleanse only the specified parameters.
|
# Cleanse only the specified parameters.
|
||||||
for param in sensitive_post_parameters:
|
for param in sensitive_post_parameters:
|
||||||
if cleansed.has_key(param):
|
if param in cleansed:
|
||||||
cleansed[param] = CLEANSED_SUBSTITUTE
|
cleansed[param] = CLEANSED_SUBSTITUTE
|
||||||
return cleansed
|
return cleansed
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue