[Checkins] SVN: z3c.caching/trunk/ Make the caching operation interfaces more useful.
Martin Aspeli
optilude at gmx.net
Thu Dec 31 05:08:21 EST 2009
Log message for revision 107438:
Make the caching operation interfaces more useful.
Changed:
U z3c.caching/trunk/README.txt
U z3c.caching/trunk/src/z3c/caching/interfaces.py
-=-
Modified: z3c.caching/trunk/README.txt
===================================================================
--- z3c.caching/trunk/README.txt 2009-12-31 07:53:01 UTC (rev 107437)
+++ z3c.caching/trunk/README.txt 2009-12-31 10:08:21 UTC (rev 107438)
@@ -97,8 +97,7 @@
cacheRule = registry.lookup(published)
operation = getOperationFor(cacheRule)
- mutator = queryMultiAdapter((published, request,),
- IResponseMutator, name=operation)
+ mutator = queryMultiAdapter((published, request,), IResponseMutator, name=operation)
mutator(response)
Here, a cache rule is looked up for the published view. An operation is
@@ -106,8 +105,10 @@
from cache rules to operations) and invoked.
"""
- def __call__(response):
- """Mutate the response
+ def __call__(ruleset, response):
+ """Mutate the response. ``rulset`` is the name of the caching ruleset
+ that was matched. It may be ``None``. ``response`` is the current
+ HTTP response.
"""
class ICacheInterceptor(Interface):
@@ -125,18 +126,20 @@
cacheRule = registry.lookup(published)
operation = getInterceptorFor(cacheRule)
- intercept = queryMultiAdapter((published, request,),
- ICacheInterceptor, name=operation)
+ intercept = queryMultiAdapter((published, request,), ICacheInterceptor, name=operation)
if intercept(response):
return # abort rendering and return what we have
# continue as normal
"""
- def __call__(response):
- """Mutate the response if required. Return True if the response should
- be intercepted. In this case, normal rendering may be aborted and the
- response returned as-is.
+ def __call__(ruleset, response):
+ """Mutate the response if required. Return ``True`` if the response
+ should be intercepted. In this case, normal rendering may be aborted
+ and the response returned as-is.
+
+ ``rulset`` is the name of the caching ruleset that was matched. It may
+ be ``None``. ``response`` is the current HTTP response.
"""
In addition, a helper adapter interface is defined which can be used to
Modified: z3c.caching/trunk/src/z3c/caching/interfaces.py
===================================================================
--- z3c.caching/trunk/src/z3c/caching/interfaces.py 2009-12-31 07:53:01 UTC (rev 107437)
+++ z3c.caching/trunk/src/z3c/caching/interfaces.py 2009-12-31 10:08:21 UTC (rev 107438)
@@ -48,8 +48,10 @@
from cache rules to operations) and invoked.
"""
- def __call__(response):
- """Mutate the response
+ def __call__(ruleset, response):
+ """Mutate the response. ``rulset`` is the name of the caching ruleset
+ that was matched. It may be ``None``. ``response`` is the current
+ HTTP response.
"""
class ICacheInterceptor(Interface):
@@ -74,10 +76,13 @@
# continue as normal
"""
- def __call__(response):
- """Mutate the response if required. Return True if the response should
- be intercepted. In this case, normal rendering may be aborted and the
- response returned as-is.
+ def __call__(ruleset, response):
+ """Mutate the response if required. Return ``True`` if the response
+ should be intercepted. In this case, normal rendering may be aborted
+ and the response returned as-is.
+
+ ``rulset`` is the name of the caching ruleset that was matched. It may
+ be ``None``. ``response`` is the current HTTP response.
"""
class ILastModified(Interface):
More information about the checkins
mailing list