Ticket #4270: 4270.diff

File 4270.diff, 1.1 KB (added by Gary Wilson <gary.wilson@…>, 18 years ago)

Added __delitem__ to QueryDict that checks if mutable. Tests too.

  • django/http/__init__.py

    === modified file 'django/http/__init__.py'
     
    9191        self._assert_mutable()
    9292        MultiValueDict.__setitem__(self, key, value)
    9393
     94    def __delitem__(self, key):
     95        self._assert_mutable()
     96        super(QueryDict, self).__delitem__(key)
     97
    9498    def __copy__(self):
    9599        result = self.__class__('', mutable=True)
    96100        for key, value in dict.items(self):
  • tests/regressiontests/httpwrappers/tests.py

    === modified file 'tests/regressiontests/httpwrappers/tests.py'
     
    9696>>> q['name']
    9797'john'
    9898
     99>>> del q['name']
     100>>> 'name' in q
     101False
     102
     103>>> q['name'] = 'john'
     104
    99105>>> q.get('foo', 'default')
    100106'default'
    101107
     
    367373>>> q.urlencode()
    368374'vote=yes&vote=no'
    369375
     376>>> del q['vote']
     377Traceback (most recent call last):
     378...
     379AttributeError: This QueryDict instance is immutable
     380
    370381"""
    371382
    372383from django.http import QueryDict
Back to Top