Ticket #7515: session_clear.diff

File session_clear.diff, 1014 bytes (added by mrts, 16 years ago)
  • django/contrib/sessions/tests.py

     
    147147>>> list(i)
    148148[('x', 1)]
    149149
     150# test .clear()
     151>>> s.modified = s.accessed = False
     152>>> s.items()
     153[('x', 1)]
     154>>> s.clear()
     155>>> s.items()
     156[]
     157>>> s.accessed, s.modified
     158(True, True)
    150159 
    151160
    152161#########################
  • django/contrib/sessions/backends/base.py

     
    5252        self.modified = self.modified or key in self._session
    5353        return self._session.pop(key, *args)
    5454
     55    def clear(self):
     56        self._session.clear()
     57        self.modified = True
     58
    5559    def setdefault(self, key, value):
    5660        if key in self._session:
    5761            return self._session[key]
Back to Top