From f9c1e52dc7c45f50bace8fbde9cc3f79e3f588b6 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 3 Mar 2012 12:40:53 +0100 Subject: [PATCH] dont save sessiondata twice, leads to datalost if run in web and celery process --- pandora/user/models.py | 3 +-- pandora/user/tasks.py | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora/user/models.py b/pandora/user/models.py index c49c6e093..d734bc60e 100644 --- a/pandora/user/models.py +++ b/pandora/user/models.py @@ -94,7 +94,6 @@ class SessionData(models.Model): except: self.location = '' pass - super(SessionData, self).save() def save(self, *args, **kwargs): if self.user: @@ -106,7 +105,6 @@ class SessionData(models.Model): self.level = 0 self.groupssort = None super(SessionData, self).save(*args, **kwargs) - tasks.parse_data.delay(self.session_key) @classmethod def get_or_create(cls, request): @@ -133,6 +131,7 @@ class SessionData(models.Model): data.timesseen += 1 data.lastseen = datetime.now() data.save() + tasks.parse_data.delay(data.session_key) return data def get_id(self): diff --git a/pandora/user/tasks.py b/pandora/user/tasks.py index c9508afcf..1e80c969a 100644 --- a/pandora/user/tasks.py +++ b/pandora/user/tasks.py @@ -15,3 +15,4 @@ import models def parse_data(key): session_data = models.SessionData.objects.get(session_key=key) session_data.parse_data() + session_data.save()