Code

Ticket #6081: ticket_6081__rev_6794.diff

File ticket_6081__rev_6794.diff, 1.9 KB (added by __hawkeye__, 6 years ago)

Removes functions specified in ticket.

Line 
1Index: django/contrib/sessions/models.py
2===================================================================
3--- django/contrib/sessions/models.py   (revision 6794)
4+++ django/contrib/sessions/models.py   (working copy)
5@@ -18,40 +18,6 @@
6         pickled_md5 = md5.new(pickled + settings.SECRET_KEY).hexdigest()
7         return base64.encodestring(pickled + pickled_md5)
8 
9-    def get_new_session_key(self):
10-        "Returns session key that isn't being used."
11-        # The random module is seeded when this Apache child is created.
12-        # Use SECRET_KEY as added salt.
13-        try:
14-            pid = os.getpid()
15-        except AttributeError:
16-            # No getpid() in Jython, for example
17-            pid = 1
18-        while 1:
19-            session_key = md5.new("%s%s%s%s" % (random.randint(0, sys.maxint - 1), pid, time.time(), settings.SECRET_KEY)).hexdigest()
20-            try:
21-                self.get(session_key=session_key)
22-            except self.model.DoesNotExist:
23-                break
24-        return session_key
25-
26-    def get_new_session_object(self):
27-        """
28-        Returns a new session object.
29-        """
30-        # FIXME: There is a *small* chance of collision here, meaning we will
31-        # return an existing object. That can be fixed when we add a way to
32-        # validate (and guarantee) that non-auto primary keys are unique. For
33-        # now, we save immediately in order to reduce the "window of
34-        # misfortune" as much as possible.
35-        created = False
36-        while not created:
37-            obj, created = self.get_or_create(session_key=self.get_new_session_key(),
38-                    expire_date = datetime.datetime.now())
39-            # Collision in key generation, so re-seed the generator
40-            random.seed()
41-        return obj
42-
43     def save(self, session_key, session_dict, expire_date):
44         s = self.model(session_key, self.encode(session_dict), expire_date)
45         if session_dict: