Ticket #11555: 11555.diff
File 11555.diff, 4.7 KB (added by , 14 years ago) |
---|
-
django/contrib/sessions/tests.py
170 170 # session key; make sure that entry is manually deleted 171 171 session.delete('1') 172 172 173 def test_session_key_is_read_only(self): 174 def set_session_key(session): 175 session.session_key = session._get_new_session_key() 176 self.assertRaises(AttributeError, set_session_key, self.session) 177 173 178 # Custom session expiry 174 179 def test_default_expiry(self): 175 180 # A normal session has a max age equal to settings -
django/contrib/sessions/backends/base.py
168 168 break 169 169 return session_key 170 170 171 def _get_ session_key(self):171 def _get_or_create_session_key(self): 172 172 if self._session_key: 173 173 return self._session_key 174 174 else: 175 175 self._session_key = self._get_new_session_key() 176 176 return self._session_key 177 177 178 def _ set_session_key(self, session_key):179 self._session_key =session_key178 def _get_session_key(self): 179 return self._session_key 180 180 181 session_key = property(_get_session_key , _set_session_key)181 session_key = property(_get_session_key) 182 182 183 183 def _get_session(self, no_load=False): 184 184 """ -
django/contrib/sessions/backends/file.py
33 33 Get the file associated with this session key. 34 34 """ 35 35 if session_key is None: 36 session_key = self. session_key36 session_key = self._get_or_create_session_key() 37 37 38 38 # Make sure we're not vulnerable to directory traversal. Session keys 39 39 # should always be md5s, so they should never contain directory -
django/contrib/sessions/backends/cache.py
23 23 # and then raise an exception. That's the risk you shoulder if using 24 24 # cache backing. 25 25 for i in xrange(10000): 26 self. session_key = self._get_new_session_key()26 self._session_key = self._get_new_session_key() 27 27 try: 28 28 self.save(must_create=True) 29 29 except CreateError: … … 37 37 func = self._cache.add 38 38 else: 39 39 func = self._cache.set 40 result = func(self.session_key, self._get_session(no_load=must_create), 40 result = func(self._get_or_create_session_key(), 41 self._get_session(no_load=must_create), 41 42 self.get_expiry_age()) 42 43 if must_create and not result: 43 44 raise CreateError -
django/contrib/sessions/backends/db.py
33 33 34 34 def create(self): 35 35 while True: 36 self. session_key = self._get_new_session_key()36 self._session_key = self._get_new_session_key() 37 37 try: 38 38 # Save immediately to ensure we have a unique entry in the 39 39 # database. … … 53 53 entry). 54 54 """ 55 55 obj = Session( 56 session_key = self. session_key,56 session_key = self._get_or_create_session_key(), 57 57 session_data = self.encode(self._get_session(no_load=must_create)), 58 58 expire_date = self.get_expiry_date() 59 59 ) -
tests/regressiontests/test_client_regress/session.py
14 14 return False 15 15 16 16 def create(self): 17 self. session_key = self.encode({})17 self._session_key = self.encode({}) 18 18 19 19 def save(self, must_create=False): 20 self. session_key = self.encode(self._session)20 self._session_key = self.encode(self._session) 21 21 22 22 def delete(self, session_key=None): 23 self. session_key = self.encode({})23 self._session_key = self.encode({}) 24 24 25 25 def load(self): 26 26 try: