Ticket #4040: 4040.diff

File 4040.diff, 39.0 KB (added by Gary Wilson <gary.wilson@…>, 8 years ago)

replaced most has_key()'s with in

  • django/bin/profiling/gather_profile_stats.py

    === modified file 'django/bin/profiling/gather_profile_stats.py'
     
    2222        else:
    2323            continue
    2424        print "Processing %s" % f
    25         if profiles.has_key(path):
     25        if path in profiles:
    2626            profiles[path].add(prof)
    2727        else:
    2828            profiles[path] = prof
  • django/contrib/admin/templatetags/admin_modify.py

    === modified file 'django/contrib/admin/templatetags/admin_modify.py'
     
    7474        self.bound_field_var = bound_field_var
    7575
    7676    def get_nodelist(cls, klass):
    77         if not cls.nodelists.has_key(klass):
     77        if klass not in cls.nodelists:
    7878            try:
    7979                field_class_name = klass.__name__
    8080                template_name = "widget/%s.html" % class_name_to_underscored(field_class_name)
  • django/contrib/admin/views/auth.py

    === modified file 'django/contrib/admin/views/auth.py'
     
    1717        if not errors:
    1818            new_user = manipulator.save(new_data)
    1919            msg = _('The %(name)s "%(obj)s" was added successfully.') % {'name': 'user', 'obj': new_user}
    20             if request.POST.has_key("_addanother"):
     20            if "_addanother" in request.POST:
    2121                request.user.message_set.create(message=msg)
    2222                return HttpResponseRedirect(request.path)
    2323            else:
     
    2929    return render_to_response('admin/auth/user/add_form.html', {
    3030        'title': _('Add user'),
    3131        'form': form,
    32         'is_popup': request.REQUEST.has_key('_popup'),
     32        'is_popup': '_popup' in request.REQUEST,
    3333        'add': True,
    3434        'change': False,
    3535        'has_delete_permission': False,
     
    6363    return render_to_response('admin/auth/user/change_password.html', {
    6464        'title': _('Change password: %s') % escape(user.username),
    6565        'form': form,
    66         'is_popup': request.REQUEST.has_key('_popup'),
     66        'is_popup': '_popup' in request.REQUEST,
    6767        'add': True,
    6868        'change': False,
    6969        'has_delete_permission': False,
  • django/contrib/admin/views/decorators.py

    === modified file 'django/contrib/admin/views/decorators.py'
     
    1212
    1313def _display_login_form(request, error_message=''):
    1414    request.session.set_test_cookie()
    15     if request.POST and request.POST.has_key('post_data'):
     15    if request.POST and 'post_data' in request.POST:
    1616        # User has failed login BUT has previously saved post data.
    1717        post_data = request.POST['post_data']
    1818    elif request.POST:
     
    4848    def _checklogin(request, *args, **kwargs):
    4949        if request.user.is_authenticated() and request.user.is_staff:
    5050            # The user is valid. Continue to the admin page.
    51             if request.POST.has_key('post_data'):
     51            if 'post_data' in request.POST:
    5252                # User must have re-authenticated through a different window
    5353                # or tab.
    5454                request.POST = _decode_post_data(request.POST['post_data'])
     
    5757        assert hasattr(request, 'session'), "The Django admin requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'."
    5858
    5959        # If this isn't already the login page, display it.
    60         if not request.POST.has_key(LOGIN_FORM_KEY):
     60        if LOGIN_FORM_KEY not in request.POST:
    6161            if request.POST:
    6262                message = _("Please log in again, because your session has expired. Don't worry: Your submission has been saved.")
    6363            else:
     
    9292                # TODO: set last_login with an event.
    9393                user.last_login = datetime.datetime.now()
    9494                user.save()
    95                 if request.POST.has_key('post_data'):
     95                if 'post_data' in request.POST:
    9696                    post_data = _decode_post_data(request.POST['post_data'])
    97                     if post_data and not post_data.has_key(LOGIN_FORM_KEY):
     97                    if post_data and LOGIN_FORM_KEY not in post_data:
    9898                        # overwrite request.POST with the saved post_data, and continue
    9999                        request.POST = post_data
    100100                        request.user = user
  • django/contrib/admin/views/main.py

    === modified file 'django/contrib/admin/views/main.py'
     
    257257            msg = _('The %(name)s "%(obj)s" was added successfully.') % {'name': opts.verbose_name, 'obj': new_object}
    258258            # Here, we distinguish between different save types by checking for
    259259            # the presence of keys in request.POST.
    260             if request.POST.has_key("_continue"):
     260            if "_continue" in request.POST:
    261261                request.user.message_set.create(message=msg + ' ' + _("You may edit it again below."))
    262                 if request.POST.has_key("_popup"):
     262                if "_popup" in request.POST:
    263263                    post_url_continue += "?_popup=1"
    264264                return HttpResponseRedirect(post_url_continue % pk_value)
    265             if request.POST.has_key("_popup"):
     265            if "_popup" in request.POST:
    266266                if type(pk_value) is str: # Quote if string, so JavaScript doesn't think it's a variable.
    267267                    pk_value = '"%s"' % pk_value.replace('"', '\\"')
    268268                return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, %s, "%s");</script>' % \
    269269                    (pk_value, str(new_object).replace('"', '\\"')))
    270             elif request.POST.has_key("_addanother"):
     270            elif "_addanother" in request.POST:
    271271                request.user.message_set.create(message=msg + ' ' + (_("You may add another %s below.") % opts.verbose_name))
    272272                return HttpResponseRedirect(request.path)
    273273            else:
     
    288288    c = template.RequestContext(request, {
    289289        'title': _('Add %s') % opts.verbose_name,
    290290        'form': form,
    291         'is_popup': request.REQUEST.has_key('_popup'),
     291        'is_popup': '_popup' in request.REQUEST,
    292292        'show_delete': show_delete,
    293293    })
    294294
     
    308308    if not request.user.has_perm(app_label + '.' + opts.get_change_permission()):
    309309        raise PermissionDenied
    310310
    311     if request.POST and request.POST.has_key("_saveasnew"):
     311    if request.POST and "_saveasnew" in request.POST:
    312312        return add_stage(request, app_label, model_name, form_url='../../add/')
    313313
    314314    try:
     
    343343            LogEntry.objects.log_action(request.user.id, ContentType.objects.get_for_model(model).id, pk_value, str(new_object), CHANGE, change_message)
    344344
    345345            msg = _('The %(name)s "%(obj)s" was changed successfully.') % {'name': opts.verbose_name, 'obj': new_object}
    346             if request.POST.has_key("_continue"):
     346            if "_continue" in request.POST:
    347347                request.user.message_set.create(message=msg + ' ' + _("You may edit it again below."))
    348                 if request.REQUEST.has_key('_popup'):
     348                if '_popup' in request.REQUEST:
    349349                    return HttpResponseRedirect(request.path + "?_popup=1")
    350350                else:
    351351                    return HttpResponseRedirect(request.path)
    352             elif request.POST.has_key("_saveasnew"):
     352            elif "_saveasnew" in request.POST:
    353353                request.user.message_set.create(message=_('The %(name)s "%(obj)s" was added successfully. You may edit it again below.') % {'name': opts.verbose_name, 'obj': new_object})
    354354                return HttpResponseRedirect("../%s/" % pk_value)
    355             elif request.POST.has_key("_addanother"):
     355            elif "_addanother" in request.POST:
    356356                request.user.message_set.create(message=msg + ' ' + (_("You may add another %s below.") % opts.verbose_name))
    357357                return HttpResponseRedirect("../add/")
    358358            else:
     
    392392        'form': form,
    393393        'object_id': object_id,
    394394        'original': manipulator.original_object,
    395         'is_popup': request.REQUEST.has_key('_popup'),
     395        'is_popup': '_popup' in request.REQUEST,
    396396    })
    397397    return render_change_form(model, manipulator, c, change=True)
    398398change_stage = staff_member_required(never_cache(change_stage))
     
    558558            self.page_num = int(request.GET.get(PAGE_VAR, 0))
    559559        except ValueError:
    560560            self.page_num = 0
    561         self.show_all = request.GET.has_key(ALL_VAR)
    562         self.is_popup = request.GET.has_key(IS_POPUP_VAR)
     561        self.show_all = ALL_VAR in request.GET
     562        self.is_popup = IS_POPUP_VAR in request.GET
    563563        self.params = dict(request.GET.items())
    564         if self.params.has_key(PAGE_VAR):
     564        if PAGE_VAR in self.params:
    565565            del self.params[PAGE_VAR]
    566         if self.params.has_key(ERROR_FLAG):
     566        if ERROR_FLAG in self.params:
    567567            del self.params[ERROR_FLAG]
    568568
    569569        self.order_field, self.order_type = self.get_ordering()
     
    594594                if k.startswith(r):
    595595                    del p[k]
    596596        for k, v in new_params.items():
    597             if p.has_key(k) and v is None:
     597            if k in p and v is None:
    598598                del p[k]
    599599            elif v is not None:
    600600                p[k] = v
     
    656656            order_field, order_type = ordering[0][1:], 'desc'
    657657        else:
    658658            order_field, order_type = ordering[0], 'asc'
    659         if params.has_key(ORDER_VAR):
     659        if ORDER_VAR in params:
    660660            try:
    661661                field_name = lookup_opts.admin.list_display[int(params[ORDER_VAR])]
    662662                try:
     
    674674                        order_field = f.name
    675675            except (IndexError, ValueError):
    676676                pass # Invalid ordering specified. Just use the default.
    677         if params.has_key(ORDER_TYPE_VAR) and params[ORDER_TYPE_VAR] in ('asc', 'desc'):
     677        if ORDER_TYPE_VAR in params and params[ORDER_TYPE_VAR] in ('asc', 'desc'):
    678678            order_type = params[ORDER_TYPE_VAR]
    679679        return order_field, order_type
    680680
     
    682682        qs = self.manager.get_query_set()
    683683        lookup_params = self.params.copy() # a dictionary of the query string
    684684        for i in (ALL_VAR, ORDER_VAR, ORDER_TYPE_VAR, SEARCH_VAR, IS_POPUP_VAR):
    685             if lookup_params.has_key(i):
     685            if i in lookup_params:
    686686                del lookup_params[i]
    687687
    688688        # Apply lookup parameters from the query string.
  • django/contrib/comments/templatetags/comments.py

    === modified file 'django/contrib/comments/templatetags/comments.py'
     
    114114        comment_list = get_list_function(**kwargs).order_by(self.ordering + 'submit_date').select_related()
    115115
    116116        if not self.free:
    117             if context.has_key('user') and context['user'].is_authenticated():
     117            if 'user' in context and context['user'].is_authenticated():
    118118                user_id = context['user'].id
    119119                context['user_can_moderate_comments'] = Comment.objects.user_is_moderator(context['user'])
    120120            else:
  • django/contrib/comments/views/comments.py

    === modified file 'django/contrib/comments/views/comments.py'
     
    217217    errors = manipulator.get_validation_errors(new_data)
    218218    # If user gave correct username/password and wasn't already logged in, log them in
    219219    # so they don't have to enter a username/password again.
    220     if manipulator.get_user() and not manipulator.get_user().is_authenticated() and new_data.has_key('password') and manipulator.get_user().check_password(new_data['password']):
     220    if manipulator.get_user() and not manipulator.get_user().is_authenticated() and 'password' in new_data and manipulator.get_user().check_password(new_data['password']):
    221221        from django.contrib.auth import login
    222222        login(request, manipulator.get_user())
    223     if errors or request.POST.has_key('preview'):
     223    if errors or 'preview' in request.POST:
    224224        class CommentFormWrapper(oldforms.FormWrapper):
    225225            def __init__(self, manipulator, new_data, errors, rating_choices):
    226226                oldforms.FormWrapper.__init__(self, manipulator, new_data, errors)
     
    244244            'rating_range': rating_range,
    245245            'rating_choices': rating_choices,
    246246        }, context_instance=RequestContext(request))
    247     elif request.POST.has_key('post'):
     247    elif 'post' in request.POST:
    248248        # If the IP is banned, mail the admins, do NOT save the comment, and
    249249        # serve up the "Thanks for posting" page as if the comment WAS posted.
    250250        if request.META['REMOTE_ADDR'] in settings.BANNED_IPS:
     
    298298    new_data['is_public'] = IS_PUBLIC in option_list
    299299    manipulator = PublicFreeCommentManipulator()
    300300    errors = manipulator.get_validation_errors(new_data)
    301     if errors or request.POST.has_key('preview'):
     301    if errors or 'preview' in request.POST:
    302302        comment = errors and '' or manipulator.get_comment(new_data)
    303303        return render_to_response('comments/free_preview.html', {
    304304            'comment': comment,
     
    307307            'target': target,
    308308            'hash': security_hash,
    309309        }, context_instance=RequestContext(request))
    310     elif request.POST.has_key('post'):
     310    elif 'post' in request.POST:
    311311        # If the IP is banned, mail the admins, do NOT save the comment, and
    312312        # serve up the "Thanks for posting" page as if the comment WAS posted.
    313313        if request.META['REMOTE_ADDR'] in settings.BANNED_IPS:
     
    330330            The object the comment was posted on
    331331    """
    332332    obj = None
    333     if request.GET.has_key('c'):
     333    if 'c' in request.GET:
    334334        content_type_id, object_id = request.GET['c'].split(':')
    335335        try:
    336336            content_type = ContentType.objects.get(pk=content_type_id)
  • django/contrib/sitemaps/views.py

    === modified file 'django/contrib/sitemaps/views.py'
     
    1616def sitemap(request, sitemaps, section=None):
    1717    maps, urls = [], []
    1818    if section is not None:
    19         if not sitemaps.has_key(section):
     19        if section not in sitemaps:
    2020            raise Http404("No sitemap available for section: %r" % section)
    2121        maps.append(sitemaps[section])
    2222    else:
  • django/core/cache/backends/simple.py

    === modified file 'django/core/cache/backends/simple.py'
     
    5252            pass
    5353
    5454    def has_key(self, key):
    55         return self._cache.has_key(key)
     55        return key in self._cache
    5656
    5757    def _cull(self):
    5858        if self._cull_frequency == 0:
  • django/core/handlers/modpython.py

    === modified file 'django/core/handlers/modpython.py'
     
    4242
    4343    def is_secure(self):
    4444        # Note: modpython 3.2.10+ has req.is_https(), but we need to support previous versions
    45         return self._req.subprocess_env.has_key('HTTPS') and self._req.subprocess_env['HTTPS'] == 'on'
     45        return 'HTTPS' in self._req.subprocess_env and self._req.subprocess_env['HTTPS'] == 'on'
    4646
    4747    def _load_post_and_files(self):
    4848        "Populates self._post and self._files"
    49         if self._req.headers_in.has_key('content-type') and self._req.headers_in['content-type'].startswith('multipart'):
     49        if 'content-type' in self._req.headers_in and self._req.headers_in['content-type'].startswith('multipart'):
    5050            self._post, self._files = http.parse_file_upload(self._req.headers_in, self.raw_post_data)
    5151        else:
    5252            self._post, self._files = http.QueryDict(self.raw_post_data), datastructures.MultiValueDict()
  • django/core/handlers/wsgi.py

    === modified file 'django/core/handlers/wsgi.py'
     
    103103        return '%s%s' % (self.path, self.environ.get('QUERY_STRING', '') and ('?' + self.environ.get('QUERY_STRING', '')) or '')
    104104
    105105    def is_secure(self):
    106         return self.environ.has_key('HTTPS') and self.environ['HTTPS'] == 'on'
     106        return 'HTTPS' in self.environ and self.environ['HTTPS'] == 'on'
    107107
    108108    def _load_post_and_files(self):
    109109        # Populates self._post and self._files
  • django/core/management.py

    === modified file 'django/core/management.py'
     
    314314            # Drop the table now
    315315            output.append('%s %s;' % (style.SQL_KEYWORD('DROP TABLE'),
    316316                style.SQL_TABLE(backend.quote_name(model._meta.db_table))))
    317             if backend.supports_constraints and references_to_delete.has_key(model):
     317            if backend.supports_constraints and model in references_to_delete:
    318318                for rel_class, f in references_to_delete[model]:
    319319                    table = rel_class._meta.db_table
    320320                    col = f.column
     
    843843                att_name += '_field'
    844844                comment_notes.append('Field renamed because it was a Python reserved word.')
    845845
    846             if relations.has_key(i):
     846            if i in relations:
    847847                rel_to = relations[i][1] == table_name and "'self'" or table2model(relations[i][1])
    848848                field_type = 'ForeignKey(%s' % rel_to
    849849                if att_name.endswith('_id'):
     
    15501550        action = args[0]
    15511551    except IndexError:
    15521552        parser.print_usage_and_exit()
    1553     if not action_mapping.has_key(action):
     1553    if action not in action_mapping:
    15541554        print_error("Your action, %r, was invalid." % action, argv[0])
    15551555
    15561556    # Switch to English, because django-admin.py creates database content
  • django/core/servers/basehttp.py

    === modified file 'django/core/servers/basehttp.py'
     
    208208    else:
    209209        return 'http'
    210210
    211 _hoppish = {
     211_hop_headers = {
    212212    'connection':1, 'keep-alive':1, 'proxy-authenticate':1,
    213213    'proxy-authorization':1, 'te':1, 'trailers':1, 'transfer-encoding':1,
    214214    'upgrade':1
    215 }.has_key
     215}
    216216
    217217def is_hop_by_hop(header_name):
    218218    """Return true if 'header_name' is an HTTP/1.1 "Hop-by-Hop" header"""
    219     return _hoppish(header_name.lower())
     219    return header_name.lower() in _hop_headers
    220220
    221221class ServerHandler(object):
    222222    """Manage the invocation of a WSGI application"""
     
    334334
    335335        Subclasses can extend this to add other defaults.
    336336        """
    337         if not self.headers.has_key('Content-Length'):
     337        if 'Content-Length' not in self.headers:
    338338            self.set_content_length()
    339339
    340340    def start_response(self, status, headers,exc_info=None):
     
    368368        if self.origin_server:
    369369            if self.client_is_modern():
    370370                self._write('HTTP/%s %s\r\n' % (self.http_version,self.status))
    371                 if not self.headers.has_key('Date'):
     371                if 'Date' not in self.headers:
    372372                    self._write(
    373373                        'Date: %s\r\n' % time.asctime(time.gmtime(time.time()))
    374374                    )
    375                 if self.server_software and not self.headers.has_key('Server'):
     375                if self.server_software and 'Server' not in self.headers:
    376376                    self._write('Server: %s\r\n' % self.server_software)
    377377        else:
    378378            self._write('Status: %s\r\n' % self.status)
  • django/core/validators.py

    === modified file 'django/core/validators.py'
     
    284284        self.always_test = True
    285285
    286286    def __call__(self, field_data, all_data):
    287         if all_data.has_key(self.other_field) and all_data[self.other_field] == self.other_value:
     287        if self.other_field in all_data and all_data[self.other_field] == self.other_value:
    288288            for v in self.validator_list:
    289289                v(field_data, all_data)
    290290
     
    322322        self.always_test = True
    323323
    324324    def __call__(self, field_data, all_data):
    325         if all_data.has_key(self.other_field) and all_data[self.other_field] == self.other_value and not field_data:
     325        if self.other_field in all_data and all_data[self.other_field] == self.other_value and not field_data:
    326326            raise ValidationError(self.error_message)
    327327
    328328class RequiredIfOtherFieldDoesNotEqual(object):
     
    335335        self.always_test = True
    336336
    337337    def __call__(self, field_data, all_data):
    338         if all_data.has_key(self.other_field) and all_data[self.other_field] != self.other_value and not field_data:
     338        if self.other_field in all_data and all_data[self.other_field] != self.other_value and not field_data:
    339339            raise ValidationError(self.error_message)
    340340
    341341class IsLessThanOtherField(object):
  • django/db/backends/mysql_old/base.py

    === modified file 'django/db/backends/mysql_old/base.py'
     
    5252            raise Database.Warning, "%s: %s" % (w, self.cursor.fetchall())
    5353
    5454    def __getattr__(self, attr):
    55         if self.__dict__.has_key(attr):
     55        if attr in self.__dict__:
    5656            return self.__dict__[attr]
    5757        else:
    5858            return getattr(self.cursor, attr)
  • django/db/backends/postgresql/base.py

    === modified file 'django/db/backends/postgresql/base.py'
     
    4747        return self.cursor.executemany(sql, new_param_list)
    4848
    4949    def __getattr__(self, attr):
    50         if self.__dict__.has_key(attr):
     50        if attr in self.__dict__:
    5151            return self.__dict__[attr]
    5252        else:
    5353            return getattr(self.cursor, attr)
  • django/db/backends/util.py

    === modified file 'django/db/backends/util.py'
     
    3333            })
    3434
    3535    def __getattr__(self, attr):
    36         if self.__dict__.has_key(attr):
     36        if attr in self.__dict__:
    3737            return self.__dict__[attr]
    3838        else:
    3939            return getattr(self.cursor, attr)
  • django/db/models/fields/__init__.py

    === modified file 'django/db/models/fields/__init__.py'
     
    779779        kwargs['maxlength'] = kwargs.get('maxlength', 50)
    780780        kwargs.setdefault('validator_list', []).append(validators.isSlug)
    781781        # Set db_index=True unless it's been set manually.
    782         if not kwargs.has_key('db_index'):
     782        if 'db_index' not in kwargs:
    783783            kwargs['db_index'] = True
    784784        Field.__init__(self, *args, **kwargs)
    785785
  • django/db/models/fields/generic.py

    === modified file 'django/db/models/fields/generic.py'
     
    3737    def instance_pre_init(self, signal, sender, args, kwargs):
    3838        # Handle initalizing an object with the generic FK instaed of
    3939        # content-type/object-id fields.       
    40         if kwargs.has_key(self.name):
     40        if self.name in kwargs:
    4141            value = kwargs.pop(self.name)
    4242            kwargs[self.ct_field] = self.get_content_type(value)
    4343            kwargs[self.fk_field] = value._get_pk_val()
  • django/db/models/fields/related.py

    === modified file 'django/db/models/fields/related.py'
     
    474474            to_field = to_field or to._meta.pk.name
    475475        kwargs['verbose_name'] = kwargs.get('verbose_name', '')
    476476
    477         if kwargs.has_key('edit_inline_type'):
     477        if 'edit_inline_type' in kwargs:
    478478            import warnings
    479479            warnings.warn("edit_inline_type is deprecated. Use edit_inline instead.")
    480480            kwargs['edit_inline'] = kwargs.pop('edit_inline_type')
     
    567567            to_field = to_field or to._meta.pk.name
    568568        kwargs['verbose_name'] = kwargs.get('verbose_name', '')
    569569
    570         if kwargs.has_key('edit_inline_type'):
     570        if 'edit_inline_type' in kwargs:
    571571            import warnings
    572572            warnings.warn("edit_inline_type is deprecated. Use edit_inline instead.")
    573573            kwargs['edit_inline'] = kwargs.pop('edit_inline_type')
  • django/db/models/loading.py

    === modified file 'django/db/models/loading.py'
     
    103103        # in the _app_models dictionary
    104104        model_name = model._meta.object_name.lower()
    105105        model_dict = _app_models.setdefault(app_label, {})
    106         if model_dict.has_key(model_name):
     106        if model_name in model_dict:
    107107            # The same model may be imported via different paths (e.g.
    108108            # appname.models and project.appname.models). We use the source
    109109            # filename as a means to detect identity.
  • django/db/models/options.py

    === modified file 'django/db/models/options.py'
     
    140140    def get_follow(self, override=None):
    141141        follow = {}
    142142        for f in self.fields + self.many_to_many + self.get_all_related_objects():
    143             if override and override.has_key(f.name):
     143            if override and f.name in override:
    144144                child_override = override[f.name]
    145145            else:
    146146                child_override = None
     
    182182        # TODO: follow
    183183        if not hasattr(self, '_field_types'):
    184184            self._field_types = {}
    185         if not self._field_types.has_key(field_type):
     185        if field_type not in self._field_types:
    186186            try:
    187187                # First check self.fields.
    188188                for f in self.fields:
  • django/db/transaction.py

    === modified file 'django/db/transaction.py'
     
    4646    when no current block is running).
    4747    """
    4848    thread_ident = thread.get_ident()
    49     if state.has_key(thread_ident) and state[thread_ident]:
     49    if thread_ident in state and state[thread_ident]:
    5050        state[thread_ident].append(state[thread_ident][-1])
    5151    else:
    5252        state[thread_ident] = []
    5353        state[thread_ident].append(settings.TRANSACTIONS_MANAGED)
    54     if not dirty.has_key(thread_ident):
     54    if thread_ident not in dirty:
    5555        dirty[thread_ident] = False
    5656
    5757def leave_transaction_management():
     
    6161    those from outside. (Commits are on connection level.)
    6262    """
    6363    thread_ident = thread.get_ident()
    64     if state.has_key(thread_ident) and state[thread_ident]:
     64    if thread_ident in state and state[thread_ident]:
    6565        del state[thread_ident][-1]
    6666    else:
    6767        raise TransactionManagementError("This code isn't under transaction management")
     
    8484    changes waiting for commit.
    8585    """
    8686    thread_ident = thread.get_ident()
    87     if dirty.has_key(thread_ident):
     87    if thread_ident in dirty:
    8888        dirty[thread_ident] = True
    8989    else:
    9090        raise TransactionManagementError("This code isn't under transaction management")
     
    9696    should happen.
    9797    """
    9898    thread_ident = thread.get_ident()
    99     if dirty.has_key(thread_ident):
     99    if thread_ident in dirty:
    100100        dirty[thread_ident] = False
    101101    else:
    102102        raise TransactionManagementError("This code isn't under transaction management")
     
    106106    Checks whether the transaction manager is in manual or in auto state.
    107107    """
    108108    thread_ident = thread.get_ident()
    109     if state.has_key(thread_ident):
     109    if thread_ident in state:
    110110        if state[thread_ident]:
    111111            return state[thread_ident][-1]
    112112    return settings.TRANSACTIONS_MANAGED
  • django/http/__init__.py

    === modified file 'django/http/__init__.py'
     
    2929
    3030    def __getitem__(self, key):
    3131        for d in (self.POST, self.GET):
    32             if d.has_key(key):
     32            if key in d:
    3333                return d[key]
    3434        raise KeyError, "%s not found in either POST or GET" % key
    3535
    3636    def has_key(self, key):
    37         return self.GET.has_key(key) or self.POST.has_key(key)
     37        return key in self.GET or key in self.POST
    3838
    3939    def get_full_path(self):
    4040        return ''
     
    5757            # name_dict is something like {'name': 'file', 'filename': 'test.txt'} for file uploads
    5858            # or {'name': 'blah'} for POST fields
    5959            # We assume all uploaded files have a 'filename' set.
    60             if name_dict.has_key('filename'):
     60            if 'filename' in name_dict:
    6161                assert type([]) != type(submessage.get_payload()), "Nested MIME messages are not supported"
    6262                if not name_dict['filename'].strip():
    6363                    continue
     
    6666                filename = name_dict['filename'][name_dict['filename'].rfind("\\")+1:]
    6767                FILES.appendlist(name_dict['name'], {
    6868                    'filename': filename,
    69                     'content-type': (submessage.has_key('Content-Type') and submessage['Content-Type'] or None),
     69                    'content-type': 'Content-Type' in submessage and submessage['Content-Type'] or None,
    7070                    'content': submessage.get_payload(),
    7171                })
    7272            else:
  • django/middleware/common.py

    === modified file 'django/middleware/common.py'
     
    2525        """
    2626
    2727        # Check for denied User-Agents
    28         if request.META.has_key('HTTP_USER_AGENT'):
     28        if 'HTTP_USER_AGENT' in request.META:
    2929            for user_agent_regex in settings.DISALLOWED_USER_AGENTS:
    3030                if user_agent_regex.search(request.META['HTTP_USER_AGENT']):
    3131                    return http.HttpResponseForbidden('<h1>Forbidden</h1>')
  • django/newforms/forms.py

    === modified file 'django/newforms/forms.py'
     
    244244    def as_widget(self, widget, attrs=None):
    245245        attrs = attrs or {}
    246246        auto_id = self.auto_id
    247         if auto_id and not attrs.has_key('id') and not widget.attrs.has_key('id'):
     247        if auto_id and 'id' not in attrs and 'id' not in widget.attrs:
    248248            attrs['id'] = auto_id
    249249        if not self.form.is_bound:
    250250            data = self.form.initial.get(self.name, self.field.initial)
  • django/newforms/widgets.py

    === modified file 'django/newforms/widgets.py'
     
    230230        return self.value == self.choice_value
    231231
    232232    def tag(self):
    233         if self.attrs.has_key('id'):
     233        if 'id' in self.attrs:
    234234            self.attrs['id'] = '%s_%s' % (self.attrs['id'], self.index)
    235235        final_attrs = dict(self.attrs, type='radio', name=self.name, value=self.choice_value)
    236236        if self.is_checked():
     
    276276class CheckboxSelectMultiple(SelectMultiple):
    277277    def render(self, name, value, attrs=None, choices=()):
    278278        if value is None: value = []
    279         has_id = attrs and attrs.has_key('id')
     279        has_id = attrs and 'id' in attrs
    280280        final_attrs = self.build_attrs(attrs, name=name)
    281281        output = [u'<ul>']
    282282        str_values = set([smart_unicode(v) for v in value]) # Normalize to strings.
  • django/oldforms/__init__.py

    === modified file 'django/oldforms/__init__.py'
     
    329329
    330330    def convert_post_data(self, new_data):
    331331        name = self.get_member_name()
    332         if new_data.has_key(self.field_name):
     332        if self.field_name in new_data:
    333333            d = new_data.getlist(self.field_name)
    334334            try:
    335335                converted_data = [self.__class__.html2python(data) for data in d]
  • django/template/__init__.py

    === modified file 'django/template/__init__.py'
     
    338338        return FilterExpression(token, self)
    339339
    340340    def find_filter(self, filter_name):
    341         if self.filters.has_key(filter_name):
     341        if filter_name in self.filters:
    342342            return self.filters[filter_name]
    343343        else:
    344344            raise TemplateSyntaxError, "Invalid filter: '%s'" % filter_name
  • django/template/context.py

    === modified file 'django/template/context.py'
     
    3535    def __getitem__(self, key):
    3636        "Get a variable's value, starting at the current context and going upward"
    3737        for d in self.dicts:
    38             if d.has_key(key):
     38            if key in d:
    3939                return d[key]
    4040        raise KeyError(key)
    4141
     
    4545
    4646    def has_key(self, key):
    4747        for d in self.dicts:
    48             if d.has_key(key):
     48            if key in d:
    4949                return True
    5050        return False
    5151
     
    5454
    5555    def get(self, key, otherwise=None):
    5656        for d in self.dicts:
    57             if d.has_key(key):
     57            if key in d:
    5858                return d[key]
    5959        return otherwise
    6060
  • django/template/defaulttags.py

    === modified file 'django/template/defaulttags.py'
     
    8484
    8585    def render(self, context):
    8686        nodelist = NodeList()
    87         if context.has_key('forloop'):
     87        if 'forloop' in context:
    8888            parentloop = context['forloop']
    8989        else:
    9090            parentloop = {}
     
    130130        self._varlist = varlist
    131131
    132132    def render(self, context):
    133         if context.has_key('forloop') and context['forloop']['first']:
     133        if 'forloop' in context and context['forloop']['first']:
    134134            self._last_seen = None
    135135        try:
    136136            if self._varlist:
     
    429429        name = args[1]
    430430        if not hasattr(parser, '_namedCycleNodes'):
    431431            raise TemplateSyntaxError("No named cycles in template: '%s' is not defined" % name)
    432         if not parser._namedCycleNodes.has_key(name):
     432        if name not in parser._namedCycleNodes:
    433433            raise TemplateSyntaxError("Named cycle '%s' does not exist" % name)
    434434        return parser._namedCycleNodes[name]
    435435
     
    908908    if len(bits) != 2:
    909909        raise TemplateSyntaxError, "'templatetag' statement takes one argument"
    910910    tag = bits[1]
    911     if not TemplateTagNode.mapping.has_key(tag):
     911    if tag not in TemplateTagNode.mapping:
    912912        raise TemplateSyntaxError, "Invalid templatetag argument: '%s'. Must be one of: %s" % \
    913913            (tag, TemplateTagNode.mapping.keys())
    914914    return TemplateTagNode(tag)
  • django/utils/datastructures.py

    === modified file 'django/utils/datastructures.py'
     
    4242
    4343    def has_key(self, key):
    4444        for dict in self.dicts:
    45             if dict.has_key(key):
     45            if key in dict:
    4646                return True
    4747        return False
    4848       
  • django/utils/functional.py

    === modified file 'django/utils/functional.py'
     
    4242                res = self.__func(*self.__args, **self.__kw)
    4343                return self.__dispatch[type(res)][funcname](res, *args, **kw)
    4444
    45             if not self.__dispatch.has_key(klass):
     45            if klass not in self.__dispatch:
    4646                self.__dispatch[klass] = {}
    4747            self.__dispatch[klass][funcname] = func
    4848            return __wrapper__
  • django/utils/translation/trans_real.py

    === modified file 'django/utils/translation/trans_real.py'
     
    199199    will resolve against the default translation object, again.
    200200    """
    201201    global _active
    202     if _active.has_key(currentThread()):
     202    if currentThread() in _active:
    203203        del _active[currentThread()]
    204204
    205205def get_language():
  • django/views/i18n.py

    === modified file 'django/views/i18n.py'
     
    9797    deliver your JavaScript source from Django templates.
    9898    """
    9999    if request.GET:
    100         if request.GET.has_key('language'):
     100        if 'language' in request.GET:
    101101            if check_for_language(request.GET['language']):
    102102                activate(request.GET['language'])
    103103    if packages is None:
     
    136136                t.update(catalog._catalog)
    137137    src = [LibHead]
    138138    plural = None
    139     if t.has_key(''):
     139    if '' in t:
    140140        for l in t[''].split('\n'):
    141141            if l.startswith('Plural-Forms:'):
    142142                plural = l.split(':',1)[1].strip()
     
    155155        if type(k) in (str, unicode):
    156156            csrc.append("catalog['%s'] = '%s';\n" % (javascript_quote(k), javascript_quote(v)))
    157157        elif type(k) == tuple:
    158             if not pdict.has_key(k[0]):
     158            if k[0] not in pdict:
    159159                pdict[k[0]] = k[1]
    160160            else:
    161161                pdict[k[0]] = max(k[1], pdict[k[0]])
  • tests/regressiontests/dispatch/tests/test_saferef.py

    === modified file 'tests/regressiontests/dispatch/tests/test_saferef.py'
     
    5555        for t in self.ts:
    5656            if hasattr(t, 'x'):
    5757                self.assert_(sd.has_key(safeRef(t.x)))
     58                self.assert_(safeRef(t.x) in sd)
    5859            else:
    5960                self.assert_(sd.has_key(safeRef(t)))
     61                self.assert_(safeRef(t) in sd)
    6062   
    6163    def testRepresentation (self):
    6264        """Test that the reference object's representation works
  • tests/regressiontests/httpwrappers/tests.py

    === modified file 'tests/regressiontests/httpwrappers/tests.py'
     
    3434>>> q.has_key('foo')
    3535False
    3636
     37>>> 'foo' in q
     38False
     39
    3740>>> q.items()
    3841[]
    3942
     
    124127>>> q.has_key('foo')
    125128True
    126129
     130>>> 'foo' in q
     131True
     132
    127133>>> q.items()
    128134[('foo', 'another'), ('name', 'john')]
    129135
     
    218224>>> q.has_key('foo')
    219225True
    220226
     227>>> 'foo' in q
     228True
     229
    221230>>> q.has_key('bar')
    222231False
    223232
     233>>> 'bar' in q
     234False
     235
    224236>>> q.items()
    225237[('foo', 'bar')]
    226238
     
    303315>>> q.has_key('vote')
    304316True
    305317
     318>>> 'vote' in q
     319True
     320
    306321>>> q.has_key('foo')
    307322False
    308323
     324>>> 'foo' in q
     325False
     326
    309327>>> q.items()
    310328[('vote', 'no')]
    311329
Back to Top