Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.support.werkzeug.wrappers.ETagResponseMixin Class Reference
Inheritance diagram for MoinMoin.support.werkzeug.wrappers.ETagResponseMixin:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def cache_control
def make_conditional
def add_etag
def set_etag
def get_etag
def freeze

Public Attributes

 status_code

Detailed Description

Adds extra functionality to a response object for etag and cache
handling.  This mixin requires an object with at least a `headers`
object that implements a dict like interface similar to :class:`Headers`.

Definition at line 827 of file wrappers.py.


Member Function Documentation

def MoinMoin.support.werkzeug.wrappers.ETagResponseMixin.add_etag (   self,
  overwrite = False,
  weak = False 
)
Add an etag for the current response if there is none yet.

Definition at line 877 of file wrappers.py.

00877 
00878     def add_etag(self, overwrite=False, weak=False):
00879         """Add an etag for the current response if there is none yet."""
00880         if overwrite or 'etag' not in self.headers:
00881             self.set_etag(generate_etag(self.data), weak)

Here is the call graph for this function:

Here is the caller graph for this function:

The Cache-Control general-header field is used to specify
directives that MUST be obeyed by all caching mechanisms along the
request/response chain.

Definition at line 834 of file wrappers.py.

00834 
00835     def cache_control(self):
00836         """The Cache-Control general-header field is used to specify
00837         directives that MUST be obeyed by all caching mechanisms along the
00838         request/response chain.
00839         """
00840         def on_update(cache_control):
00841             if not cache_control and 'cache-control' in self.headers:
00842                 del self.headers['cache-control']
00843             elif cache_control:
00844                 self.headers['Cache-Control'] = cache_control.to_header()
00845         return parse_cache_control_header(self.headers.get('cache-control'),
00846                                           on_update,
00847                                           ResponseCacheControl)

Here is the call graph for this function:

def MoinMoin.support.werkzeug.wrappers.ETagResponseMixin.freeze (   self,
  no_etag = False 
)
Call this method if you want to make your response object ready for
pickeling.  This buffers the generator if there is one.  This also
sets the etag unless `no_etag` is set to `True`.

Definition at line 892 of file wrappers.py.

00892 
00893     def freeze(self, no_etag=False):
00894         """Call this method if you want to make your response object ready for
00895         pickeling.  This buffers the generator if there is one.  This also
00896         sets the etag unless `no_etag` is set to `True`.
00897         """
00898         if not no_etag:
00899             self.add_etag()
00900         super(ETagResponseMixin, self).freeze()
00901 

Here is the call graph for this function:

Return a tuple in the form ``(etag, is_weak)``.  If there is no
ETag the return value is ``(None, None)``.

Definition at line 886 of file wrappers.py.

00886 
00887     def get_etag(self):
00888         """Return a tuple in the form ``(etag, is_weak)``.  If there is no
00889         ETag the return value is ``(None, None)``.
00890         """
00891         return unquote_etag(self.headers.get('ETag'))

Here is the call graph for this function:

Make the response conditional to the request.  This method works
best if an etag was defined for the response already.  The `add_etag`
method can be used to do that.  If called without etag just the date
header is set.

This does nothing if the request method in the request or environ is
anything but GET or HEAD.

It does not remove the body of the response because that's something
the :meth:`__call__` function does for us automatically.

Returns self so that you can do ``return resp.make_conditional(req)``
but modifies the object in-place.

:param request_or_environ: a request object or WSGI environment to be
                   used to make the response conditional
                   against.

Definition at line 848 of file wrappers.py.

00848 
00849     def make_conditional(self, request_or_environ):
00850         """Make the response conditional to the request.  This method works
00851         best if an etag was defined for the response already.  The `add_etag`
00852         method can be used to do that.  If called without etag just the date
00853         header is set.
00854 
00855         This does nothing if the request method in the request or environ is
00856         anything but GET or HEAD.
00857 
00858         It does not remove the body of the response because that's something
00859         the :meth:`__call__` function does for us automatically.
00860 
00861         Returns self so that you can do ``return resp.make_conditional(req)``
00862         but modifies the object in-place.
00863 
00864         :param request_or_environ: a request object or WSGI environment to be
00865                                    used to make the response conditional
00866                                    against.
00867         """
00868         environ = getattr(request_or_environ, 'environ', request_or_environ)
00869         if environ['REQUEST_METHOD'] in ('GET', 'HEAD'):
00870             self.headers['Date'] = http_date()
00871             if 'content-length' in self.headers:
00872                 self.headers['Content-Length'] = len(self.data)
00873             if not is_resource_modified(environ, self.headers.get('etag'), None,
00874                                         self.headers.get('last-modified')):
00875                 self.status_code = 304
00876         return self

Here is the call graph for this function:

def MoinMoin.support.werkzeug.wrappers.ETagResponseMixin.set_etag (   self,
  etag,
  weak = False 
)
Set the etag, and override the old one if there was one.

Definition at line 882 of file wrappers.py.

00882 
00883     def set_etag(self, etag, weak=False):
00884         """Set the etag, and override the old one if there was one."""
00885         self.headers['ETag'] = quote_etag(etag, weak)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 874 of file wrappers.py.


The documentation for this class was generated from the following file: