在 GAE 上订购 Django-nonrel 的中间件类

发布于 2025-01-02 10:26:52 字数 990 浏览 1 评论 0原文

谁能澄清如何订购下面的中间件类?

'mediagenerator.middleware.MediaMiddleware', 
'autoload.middleware.AutoloadMiddleware', 
'django.middleware.cache.UpdateCacheMiddleware', 
    . 
    . 
    . 
'django.middleware.cache.FetchFromCacheMiddleware',
'google.appengine.ext.appstats.recording.AppStatsDjangoMiddleware', 

在文档中,顶层组中的每个中间件都被告知要排在第一位, 底部组中的两个中间件被告知要放在最后。 这很令人困惑。 以下是我正在使用的中间件的完整列表:

'mediagenerator.middleware.MediaMiddleware', 
'autoload.middleware.AutoloadMiddleware', 
'django.middleware.cache.UpdateCacheMiddleware', 
'django.middleware.common.CommonMiddleware', 
'django.contrib.sessions.middleware.SessionMiddleware', 
'django.contrib.auth.middleware.AuthenticationMiddleware', 
'django.contrib.csrf.middleware.CsrfViewMiddleware', 
'django.middleware.csrf.CsrfResponseMiddleware', 
'django.middleware.cache.FetchFromCacheMiddleware', 
'google.appengine.ext.appstats.recording.AppStatsDjangoMiddleware',

任何帮助和解释将不胜感激。

Can anyone clarify how to order below middleware classes?

'mediagenerator.middleware.MediaMiddleware', 
'autoload.middleware.AutoloadMiddleware', 
'django.middleware.cache.UpdateCacheMiddleware', 
    . 
    . 
    . 
'django.middleware.cache.FetchFromCacheMiddleware',
'google.appengine.ext.appstats.recording.AppStatsDjangoMiddleware', 

In documents, every middleware in the top group is told to come first,
and both middleware in the bottom group is told to come last.
This is confusing.
Below is the whole list of middleware that I'm using:

'mediagenerator.middleware.MediaMiddleware', 
'autoload.middleware.AutoloadMiddleware', 
'django.middleware.cache.UpdateCacheMiddleware', 
'django.middleware.common.CommonMiddleware', 
'django.contrib.sessions.middleware.SessionMiddleware', 
'django.contrib.auth.middleware.AuthenticationMiddleware', 
'django.contrib.csrf.middleware.CsrfViewMiddleware', 
'django.middleware.csrf.CsrfResponseMiddleware', 
'django.middleware.cache.FetchFromCacheMiddleware', 
'google.appengine.ext.appstats.recording.AppStatsDjangoMiddleware',

Any help and explanation will be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倒数 2025-01-09 10:26:52

请检查一切是否正常:

'autoload.middleware.AutoloadMiddleware',   # This is loading other modules, so it goes first because we want everything set before processing.
'mediagenerator.middleware.MediaMiddleware',   # Serves/caches static files with urls starting with DEV_MEDIA_URL 
'django.middleware.cache.UpdateCacheMiddleware',   # Must be before other middleware that changes the header, so it seems that the right place for this is here
'google.appengine.ext.appstats.recording.AppStatsDjangoMiddleware', # Must be 'first' too. It collects stats of all middlewares below this. If you want stats from the middlewares above move it to the top

'django.middleware.common.CommonMiddleware', 
'django.contrib.sessions.middleware.SessionMiddleware', 
'django.contrib.auth.middleware.AuthenticationMiddleware', 
'django.contrib.csrf.middleware.CsrfViewMiddleware', 
'django.middleware.csrf.CsrfResponseMiddleware', 
'django.middleware.cache.FetchFromCacheMiddleware', 

Please check if everything is working:

'autoload.middleware.AutoloadMiddleware',   # This is loading other modules, so it goes first because we want everything set before processing.
'mediagenerator.middleware.MediaMiddleware',   # Serves/caches static files with urls starting with DEV_MEDIA_URL 
'django.middleware.cache.UpdateCacheMiddleware',   # Must be before other middleware that changes the header, so it seems that the right place for this is here
'google.appengine.ext.appstats.recording.AppStatsDjangoMiddleware', # Must be 'first' too. It collects stats of all middlewares below this. If you want stats from the middlewares above move it to the top

'django.middleware.common.CommonMiddleware', 
'django.contrib.sessions.middleware.SessionMiddleware', 
'django.contrib.auth.middleware.AuthenticationMiddleware', 
'django.contrib.csrf.middleware.CsrfViewMiddleware', 
'django.middleware.csrf.CsrfResponseMiddleware', 
'django.middleware.cache.FetchFromCacheMiddleware', 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文