summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2010-10-29 04:24:53 +0000
committerAlex Gaynor <alex.gaynor@gmail.com>2010-10-29 04:24:53 +0000
commitc38a174f7c3d2dc5a1adab746ca44f0afd0d966c (patch)
treeb3c6cd4a06714365cba5520b5fd596c09a098f08
parentcb17f7ca2252265ab4a844e7924cb8ebab4a1a76 (diff)
Remove several uses of the deprecated dict.has_key in favor of the in operator. This is faster, has less code, and is in every single way better.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14392 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/admin/options.py24
-rw-r--r--django/contrib/admin/sites.py2
-rw-r--r--django/contrib/admin/widgets.py2
-rw-r--r--django/db/models/query.py4
4 files changed, 16 insertions, 16 deletions
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 12490c88d2..6b1e5d558e 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -648,17 +648,17 @@ class ModelAdmin(BaseModelAdmin):
msg = _('The %(name)s "%(obj)s" was added successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj)}
# Here, we distinguish between different save types by checking for
# the presence of keys in request.POST.
- if request.POST.has_key("_continue"):
+ if "_continue" in request.POST:
self.message_user(request, msg + ' ' + _("You may edit it again below."))
- if request.POST.has_key("_popup"):
+ if "_popup" in request.POST:
post_url_continue += "?_popup=1"
return HttpResponseRedirect(post_url_continue % pk_value)
- if request.POST.has_key("_popup"):
+ if "_popup" in request.POST:
return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, "%s", "%s");</script>' % \
# escape() calls force_unicode.
(escape(pk_value), escape(obj)))
- elif request.POST.has_key("_addanother"):
+ elif "_addanother" in request.POST:
self.message_user(request, msg + ' ' + (_("You may add another %s below.") % force_unicode(opts.verbose_name)))
return HttpResponseRedirect(request.path)
else:
@@ -681,17 +681,17 @@ class ModelAdmin(BaseModelAdmin):
pk_value = obj._get_pk_val()
msg = _('The %(name)s "%(obj)s" was changed successfully.') % {'name': force_unicode(opts.verbose_name), 'obj': force_unicode(obj)}
- if request.POST.has_key("_continue"):
+ if "_continue" in request.POST:
self.message_user(request, msg + ' ' + _("You may edit it again below."))
- if request.REQUEST.has_key('_popup'):
+ if "_popup" in request.REQUEST:
return HttpResponseRedirect(request.path + "?_popup=1")
else:
return HttpResponseRedirect(request.path)
- elif request.POST.has_key("_saveasnew"):
+ elif "_saveasnew" in request.POST:
msg = _('The %(name)s "%(obj)s" was added successfully. You may edit it again below.') % {'name': force_unicode(opts.verbose_name), 'obj': obj}
self.message_user(request, msg)
return HttpResponseRedirect("../%s/" % pk_value)
- elif request.POST.has_key("_addanother"):
+ elif "_addanother" in request.POST:
self.message_user(request, msg + ' ' + (_("You may add another %s below.") % force_unicode(opts.verbose_name)))
return HttpResponseRedirect("../add/")
else:
@@ -793,7 +793,7 @@ class ModelAdmin(BaseModelAdmin):
prefix = "%s-%s" % (prefix, prefixes[prefix])
formset = FormSet(data=request.POST, files=request.FILES,
instance=new_object,
- save_as_new=request.POST.has_key("_saveasnew"),
+ save_as_new="_saveasnew" in request.POST,
prefix=prefix, queryset=inline.queryset(request))
formsets.append(formset)
if all_valid(formsets) and form_validated:
@@ -844,7 +844,7 @@ class ModelAdmin(BaseModelAdmin):
context = {
'title': _('Add %s') % force_unicode(opts.verbose_name),
'adminform': adminForm,
- 'is_popup': request.REQUEST.has_key('_popup'),
+ 'is_popup': "_popup" in request.REQUEST,
'show_delete': False,
'media': mark_safe(media),
'inline_admin_formsets': inline_admin_formsets,
@@ -870,7 +870,7 @@ class ModelAdmin(BaseModelAdmin):
if obj is None:
raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % {'name': force_unicode(opts.verbose_name), 'key': escape(object_id)})
- if request.method == 'POST' and request.POST.has_key("_saveasnew"):
+ if request.method == 'POST' and "_saveasnew" in request.POST:
return self.add_view(request, form_url='../add/')
ModelForm = self.get_form(request, obj)
@@ -937,7 +937,7 @@ class ModelAdmin(BaseModelAdmin):
'adminform': adminForm,
'object_id': object_id,
'original': obj,
- 'is_popup': request.REQUEST.has_key('_popup'),
+ 'is_popup': "_popup" in request.REQUEST,
'media': mark_safe(media),
'inline_admin_formsets': inline_admin_formsets,
'errors': helpers.AdminErrorList(form, formsets),
diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py
index c763b1dc17..b995c0f2df 100644
--- a/django/contrib/admin/sites.py
+++ b/django/contrib/admin/sites.py
@@ -303,7 +303,7 @@ class AdminSite(object):
from django.contrib.auth.models import User
# If this isn't already the login page, display it.
- if not request.POST.has_key(LOGIN_FORM_KEY):
+ if LOGIN_FORM_KEY not in request.POST:
if request.POST:
message = _("Please log in again, because your session has expired.")
else:
diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py
index 05b2566167..0f567bdbdd 100644
--- a/django/contrib/admin/widgets.py
+++ b/django/contrib/admin/widgets.py
@@ -111,7 +111,7 @@ class ForeignKeyRawIdWidget(forms.TextInput):
url = '?' + '&amp;'.join(['%s=%s' % (k, v) for k, v in params.items()])
else:
url = ''
- if not attrs.has_key('class'):
+ if "class" not in attrs:
attrs['class'] = 'vForeignKeyRawIdAdminField' # The JavaScript looks for this hook.
output = [super(ForeignKeyRawIdWidget, self).render(name, value, attrs)]
# TODO: "id_" is hard-coded here. This should instead use the correct
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 5969ab128c..7e91b0fc93 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -864,9 +864,9 @@ class ValuesQuerySet(QuerySet):
# we inspect the full extra_select list since we might
# be adding back an extra select item that we hadn't
# had selected previously.
- if self.query.extra.has_key(f):
+ if f in self.query.extra:
self.extra_names.append(f)
- elif self.query.aggregate_select.has_key(f):
+ elif f in self.query.aggregate_select:
self.aggregate_names.append(f)
else:
self.field_names.append(f)