summaryrefslogtreecommitdiff
path: root/django/newforms
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-04-26 13:30:48 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-04-26 13:30:48 +0000
commit439cb4047fb583d08149f28e2ce66a8edfe0efa7 (patch)
tree47ef30e70bf1d757f08b133d3aa47704db13c714 /django/newforms
parent6c02565e4fb92c4cc3bfb45bcc89eb9aa299efdc (diff)
Fixed #4040 -- Changed uses of has_key() to "in". Slight performance
improvement and forward-compatible with future Python releases. Patch from Gary Wilson. git-svn-id: http://code.djangoproject.com/svn/django/trunk@5091 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/newforms')
-rw-r--r--django/newforms/forms.py2
-rw-r--r--django/newforms/widgets.py4
2 files changed, 3 insertions, 3 deletions
diff --git a/django/newforms/forms.py b/django/newforms/forms.py
index 1f37da91ff..3df7a9e834 100644
--- a/django/newforms/forms.py
+++ b/django/newforms/forms.py
@@ -244,7 +244,7 @@ class BoundField(StrAndUnicode):
def as_widget(self, widget, attrs=None):
attrs = attrs or {}
auto_id = self.auto_id
- if auto_id and not attrs.has_key('id') and not widget.attrs.has_key('id'):
+ if auto_id and 'id' not in attrs and 'id' not in widget.attrs:
attrs['id'] = auto_id
if not self.form.is_bound:
data = self.form.initial.get(self.name, self.field.initial)
diff --git a/django/newforms/widgets.py b/django/newforms/widgets.py
index 5f1a130459..dd71ebc455 100644
--- a/django/newforms/widgets.py
+++ b/django/newforms/widgets.py
@@ -230,7 +230,7 @@ class RadioInput(StrAndUnicode):
return self.value == self.choice_value
def tag(self):
- if self.attrs.has_key('id'):
+ if 'id' in self.attrs:
self.attrs['id'] = '%s_%s' % (self.attrs['id'], self.index)
final_attrs = dict(self.attrs, type='radio', name=self.name, value=self.choice_value)
if self.is_checked():
@@ -276,7 +276,7 @@ class RadioSelect(Select):
class CheckboxSelectMultiple(SelectMultiple):
def render(self, name, value, attrs=None, choices=()):
if value is None: value = []
- has_id = attrs and attrs.has_key('id')
+ has_id = attrs and 'id' in attrs
final_attrs = self.build_attrs(attrs, name=name)
output = [u'<ul>']
str_values = set([smart_unicode(v) for v in value]) # Normalize to strings.