Code

#21000 closed Bug (fixed)

Session cached_db backend doesn't use SESSION_CACHE_ALIAS

Reported by: Cloudream Owned by: nobody
Component: contrib.sessions Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

cached_db always use default cache backend

Attachments (0)

Change History (4)

comment:1 Changed 11 months ago by Cloudream

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 11 months ago by aaugustin

  • Needs documentation set
  • Needs tests set
  • Triage Stage changed from Unreviewed to Accepted

Patch looks OK, it would be nice to add tests (or a strong rationale as to why they're impossible to write; I can't remember what support for testing multiple caches we currently have).

This is worth mentioning in the release notes too.

comment:3 Changed 11 months ago by Cloudream

Added a small test.

A weird thing: the previous code could also pass this test: (copied from CacheSessionTests in contrib/sessions/tests.py)

    @override_settings(CACHES={
        'default': {
            'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
        },
        'sessions': {
            'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
        },
    }, SESSION_CACHE_ALIAS='sessions')
    def test_non_default_cache(self):
        # Re-initalize the session backend to make use of overridden settings.
        self.session = self.backend()

        self.session.save()
        self.assertEqual(get_cache('default').get(self.session.cache_key), None)
        self.assertNotEqual(get_cache('sessions').get(self.session.cache_key), None)  # Should fail here as previous code always use `default` cache

comment:4 Changed 10 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In ed9cd4fd8b425ab5010b27aefc7ef6e50d55fb54:

Fixed #21000 -- Made cached_db session backend respect SESSION_CACHE_ALIAS

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.