Ticket #21608: session_fix.patch

File session_fix.patch, 1.1 KB (added by Jonas Borgström, 11 years ago)

Proposed fix (against django 1.4)

  • django/contrib/sessions/backends/db.py

    diff --git a/django/contrib/sessions/backends/db.py b/django/contrib/sessions/backends/db.py
    index 3dd0d95..eab9190 100644
    a b class SessionStore(SessionBase):  
    5353            expire_date=self.get_expiry_date()
    5454        )
    5555        using = router.db_for_write(Session, instance=obj)
    56         sid = transaction.savepoint(using=using)
    57         try:
    58             obj.save(force_insert=must_create, using=using)
    59         except IntegrityError:
    60             if must_create:
     56        if must_create:
     57            sid = transaction.savepoint(using=using)
     58            try:
     59                obj.save(force_insert=must_create, force_update=not must_create, using=using)
     60            except IntegrityError:
    6161                transaction.savepoint_rollback(sid, using=using)
    6262                raise CreateError
    63             raise
     63        else:
     64            Session.objects.using(using).filter(pk=obj.session_key).update(session_data=obj.session_data, expire_date=obj.expire_date)
    6465
    6566    def delete(self, session_key=None):
    6667        if session_key is None:
Back to Top