[Django] #28094: Cache settings override does not work properly

瀏覽次數:34 次
跳到第一則未讀訊息

Django

未讀,
2017年4月18日 下午4:53:222017/4/18
收件者:django-...@googlegroups.com
#28094: Cache settings override does not work properly
---------------------------------------------+------------------------
Reporter: R3turnz | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 1.11
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------------+------------------------
The following should override the CACHES setting during tests:
{{{#!python
@method_decorator(cache_page(60 * 5), name='dispatch')
class IndexView(generic.ListView):

if ENABLE_CACHING:
CACHES = get_cache()
else:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}

@override_settings(CACHES={'default': {'BACKEND':
'django.core.cache.backends.dummy.DummyCache'}})
class IndexViewTests(TestCase):
}}}
The setting also seems to be correctly overriden, (django.conf.settings
contains dummy cache) but I encounter following problems:
* The context of the response is always None.
* Test which formerly passed now fail and view functions are not called.
All problems disappear when I disable caching **manually**!
This leads me to the assumption that the views are stilled cached.
The documentation says that overriding the cache should be possible and I
am not using sessions framwork.
I do not have enough knowledge of the architecture of django to do further
debugging.

--
Ticket URL: <https://code.djangoproject.com/ticket/28094>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

未讀,
2017年4月20日 上午8:26:242017/4/20
收件者:django-...@googlegroups.com
#28094: Cache settings override does not work properly
-----------------------------------+--------------------------------------

Reporter: R3turnz | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 1.11
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by Tim Graham):

I suspect this is not a bug but that you'll have to reinitialize the
class-based view after overriding the `CACHES` setting since it's already
been initialized with the original settings values.

If that's correct, perhaps
[https://github.com/django/django/blob/43b4a1618ed85151494d68778a1bb6304ce1cb79/docs/topics/testing/tools.txt#L1265-L1270
the documentation] could be clarified.

--
Ticket URL: <https://code.djangoproject.com/ticket/28094#comment:1>

Django

未讀,
2017年4月21日 凌晨3:42:422017/4/21
收件者:django-...@googlegroups.com
#28094: Cache settings override does not work properly
-----------------------------------+--------------------------------------

Reporter: R3turnz | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 1.11
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by R3turnz):

I agree with you that this could be the problem, but how do reinitialize
the settings?

--
Ticket URL: <https://code.djangoproject.com/ticket/28094#comment:2>

Django

未讀,
2017年5月31日 上午11:20:462017/5/31
收件者:django-...@googlegroups.com
#28094: Document how @override_settings(CACHES=...) can work with class-based views
-------------------------------------+-------------------------------------
Reporter: R3turnz | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 1.11
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* type: Bug => Cleanup/optimization
* component: Testing framework => Documentation


Comment:

I'm not sure if there's an elegant way for this to work.

--
Ticket URL: <https://code.djangoproject.com/ticket/28094#comment:3>

Django

未讀,
2017年5月31日 上午11:21:002017/5/31
收件者:django-...@googlegroups.com
#28094: Document how @override_settings(CACHES=...) can work with class-based views
--------------------------------------+------------------------------------
Reporter: R3turnz | Owner: nobody
Type: Cleanup/optimization | Status: new

Component: Documentation | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/28094#comment:4>

Django

未讀,
2018年11月13日 上午11:26:122018/11/13
收件者:django-...@googlegroups.com
#28094: Document how @override_settings(CACHES=...) can work with class-based views
--------------------------------------+------------------------------------
Reporter: R3turnz | Owner: nobody

Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Kevin Graves):

* cc: Kevin Graves (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/28094#comment:5>

回覆所有人
回覆作者
轉寄
0 則新訊息