Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5-Boxiang
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Hamza
erp5-Boxiang
Commits
7187fb69
Commit
7187fb69
authored
Jul 01, 2015
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
patch : Caching Policy Manager should not override existing response headers.
parent
0e43f1f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
0 deletions
+58
-0
product/ERP5Type/ZopePatch.py
product/ERP5Type/ZopePatch.py
+1
-0
product/ERP5Type/patches/CMFCoreUtils.py
product/ERP5Type/patches/CMFCoreUtils.py
+57
-0
No files found.
product/ERP5Type/ZopePatch.py
View file @
7187fb69
...
@@ -82,6 +82,7 @@ from Products.ERP5Type.patches import ExceptionFormatter
...
@@ -82,6 +82,7 @@ from Products.ERP5Type.patches import ExceptionFormatter
from
Products.ERP5Type.patches
import
WebDAV
from
Products.ERP5Type.patches
import
WebDAV
from
Products.ERP5Type.patches
import
DTMLMethod
from
Products.ERP5Type.patches
import
DTMLMethod
from
Products.ERP5Type.patches
import
DTMLDocument
from
Products.ERP5Type.patches
import
DTMLDocument
from
Products.ERP5Type.patches
import
CMFCoreUtils
# These symbols are required for backward compatibility
# These symbols are required for backward compatibility
from
Products.ERP5Type.patches.PropertyManager
import
ERP5PropertyManager
from
Products.ERP5Type.patches.PropertyManager
import
ERP5PropertyManager
...
...
product/ERP5Type/patches/CMFCoreUtils.py
0 → 100644
View file @
7187fb69
##############################################################################
#
# Copyright (c) 2001 Zope Foundation and Contributors.
# Copyright (c) 2015 Nexedi SA and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
from
Acquisition
import
aq_parent
from
Products.CMFCore.utils
import
getToolByName
,
SUBTEMPLATE
# patch _setCacheHeaders so that existing headers are not overridden
def
_setCacheHeaders
(
obj
,
extra_context
):
"""Set cache headers according to cache policy manager for the obj."""
REQUEST
=
getattr
(
obj
,
'REQUEST'
,
None
)
if
REQUEST
is
not
None
:
call_count
=
getattr
(
REQUEST
,
SUBTEMPLATE
,
1
)
-
1
setattr
(
REQUEST
,
SUBTEMPLATE
,
call_count
)
if
call_count
!=
0
:
return
# cleanup
delattr
(
REQUEST
,
SUBTEMPLATE
)
content
=
aq_parent
(
obj
)
manager
=
getToolByName
(
obj
,
'caching_policy_manager'
,
None
)
if
manager
is
None
:
return
view_name
=
obj
.
getId
()
headers
=
manager
.
getHTTPCachingHeaders
(
content
,
view_name
,
extra_context
)
RESPONSE
=
REQUEST
[
'RESPONSE'
]
# PATCH BEGIN: do not override existing headers
ignore_list
=
[
y
[
0
].
lower
()
for
y
in
RESPONSE
.
headers
.
iteritems
()]
headers
=
[
x
for
x
in
headers
if
x
[
0
].
lower
()
not
in
ignore_list
]
# PATCH END
for
key
,
value
in
headers
:
if
key
==
'ETag'
:
RESPONSE
.
setHeader
(
key
,
value
,
literal
=
1
)
else
:
RESPONSE
.
setHeader
(
key
,
value
)
if
headers
:
RESPONSE
.
setHeader
(
'X-Cache-Headers-Set-By'
,
'CachingPolicyManager: %s'
%
'/'
.
join
(
manager
.
getPhysicalPath
()))
import
Products.CMFCore.utils
Products
.
CMFCore
.
utils
.
_setCacheHeaders
=
_setCacheHeaders
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment