[CMF-checkins] CVS: Products/CMFCore -
CachingPolicyManager.py:1.14.2.1 utils.py:1.59.2.4
Jens Vagelpohl
jens at dataflake.org
Wed Nov 10 15:32:18 EST 2004
Update of /cvs-repository/Products/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv31697/CMFCore
Modified Files:
Tag: CMF-1_5-branch
CachingPolicyManager.py utils.py
Log Message:
- CachePolicyManager: You can now set a ETag using a TALES expression
(http://www.zope.org/Collectors/CMF/236)
=== Products/CMFCore/CachingPolicyManager.py 1.14 => 1.14.2.1 ===
--- Products/CMFCore/CachingPolicyManager.py:1.14 Thu Aug 12 11:07:39 2004
+++ Products/CMFCore/CachingPolicyManager.py Wed Nov 10 15:31:48 2004
@@ -100,6 +100,10 @@
Cookie headers into account when deciding what cached object to
choose and serve in response to a request.
+ - The "ETag" HTTP response header will be set if a value is
+ provided. The value is a TALES expression and the result
+ after evaluation will be used as the ETag header value.
+
- Other tokens will be added to the "Cache-control" HTTP response
header as follows:
@@ -119,6 +123,7 @@
, no_store=0
, must_revalidate=0
, vary=''
+ , etag_func=''
):
if not predicate:
@@ -138,6 +143,7 @@
self._no_store = int( no_store )
self._must_revalidate = int( must_revalidate )
self._vary = vary
+ self._etag_func = Expression( text=etag_func )
def getPolicyId( self ):
"""
@@ -179,6 +185,17 @@
"""
return getattr(self, '_vary', '')
+ def getETagFunc( self ):
+ """
+ """
+ etag_func_text = ''
+ etag_func = getattr(self, '_etag_func', None)
+
+ if etag_func is not None:
+ etag_func_text = etag_func.text
+
+ return etag_func_text
+
def getHeaders( self, expr_context ):
"""
Does this request match our predicate? If so, return a
@@ -222,6 +239,9 @@
if self.getVary():
headers.append( ( 'Vary', self._vary ) )
+ if self.getETagFunc():
+ headers.append( ( 'ETag', self._etag_func( expr_context ) ) )
+
return headers
@@ -278,6 +298,7 @@
, no_store # boolean (def. 0)
, must_revalidate # boolean (def. 0)
, vary # string value
+ , etag_func # TALES expr (def. '')
, REQUEST=None
):
"""
@@ -291,6 +312,7 @@
, no_store
, must_revalidate
, vary
+ , etag_func
)
if REQUEST is not None:
REQUEST[ 'RESPONSE' ].redirect( self.absolute_url()
@@ -308,7 +330,8 @@
, no_cache # boolean (def. 0)
, no_store # boolean (def. 0)
, must_revalidate # boolean (def. 0)
- , vary
+ , vary # string value
+ , etag_func # TALES expr (def. '')
, REQUEST=None
):
"""
@@ -322,6 +345,7 @@
, no_store
, must_revalidate
, vary
+ , etag_func
)
if REQUEST is not None:
REQUEST[ 'RESPONSE' ].redirect( self.absolute_url()
@@ -391,6 +415,7 @@
, no_store
, must_revalidate
, vary
+ , etag_func
):
"""
Add a policy to our registry.
@@ -411,6 +436,7 @@
, no_store
, must_revalidate
, vary
+ , etag_func
)
idlist = list( self._policy_ids )
idlist.append( policy_id )
@@ -426,6 +452,7 @@
, no_store
, must_revalidate
, vary
+ , etag_func
):
"""
Update a policy in our registry.
@@ -441,6 +468,7 @@
, no_store
, must_revalidate
, vary
+ , etag_func
)
security.declarePrivate( '_reorderPolicy' )
=== Products/CMFCore/utils.py 1.59.2.3 => 1.59.2.4 ===
--- Products/CMFCore/utils.py:1.59.2.3 Wed Sep 15 05:22:40 2004
+++ Products/CMFCore/utils.py Wed Nov 10 15:31:48 2004
@@ -335,7 +335,10 @@
)
RESPONSE = REQUEST['RESPONSE']
for key, value in headers:
- RESPONSE.setHeader(key, value)
+ 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' %
More information about the CMF-checkins
mailing list