Ticket #7515: session_clear-with_docs2.diff

File session_clear-with_docs2.diff, 1.5 KB (added by mrts, 16 years ago)

Rephrased docs as per suggestions on the IRC.

  • 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]
  • docs/sessions.txt

     
    106106
    107107    * ``setdefault()`` (**New in Django development version**)
    108108
     109    * ``clear()`` (**New in Django development version**)
     110
     111      This clears all session data. It results in an empty session that is
     112      saved to the session store.
     113
    109114It also has these methods:
    110115
    111116    * ``set_test_cookie()``
Back to Top