Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Private Attributes
MoinMoin.support.werkzeug.contrib.lint.GuardedIterator Class Reference

List of all members.

Public Member Functions

def __init__
def __iter__
def next
def close
def __del__

Public Attributes

 closed
 headers_set
 chunks

Private Attributes

 _iterator
 _next

Detailed Description

Definition at line 121 of file lint.py.


Constructor & Destructor Documentation

def MoinMoin.support.werkzeug.contrib.lint.GuardedIterator.__init__ (   self,
  iterator,
  headers_set,
  chunks 
)

Definition at line 123 of file lint.py.

00123 
00124     def __init__(self, iterator, headers_set, chunks):
00125         self._iterator = iterator
00126         self._next = iter(iterator).next
00127         self.closed = False
00128         self.headers_set = headers_set
00129         self.chunks = chunks

Definition at line 175 of file lint.py.

00175 
00176     def __del__(self):
00177         if not self.closed:
00178             try:
00179                 warn(WSGIWarning('Iterator was garbage collected before '
00180                                  'it was closed.'))
00181             except:
00182                 pass
00183 


Member Function Documentation

Definition at line 130 of file lint.py.

00130 
00131     def __iter__(self):
00132         return self

Definition at line 145 of file lint.py.

00145 
00146     def close(self):
00147         self.closed = True
00148         if hasattr(self._iterator, 'close'):
00149             self._iterator.close()
00150 
00151         if self.headers_set:
00152             status_code, headers = self.headers_set
00153             bytes_sent = sum(self.chunks)
00154             content_length = headers.get('content-length', type=int)
00155 
00156             if status_code == 304:
00157                 for key, value in headers:
00158                     key = key.lower()
00159                     if key not in ('expires', 'content-location') and \
00160                        is_entity_header(key):
00161                         warn(HTTPWarning('entity header %r found in 304 '
00162                             'response' % key))
00163                 if bytes_sent:
00164                     warn(HTTPWarning('304 responses must not have a body'))
00165             elif 100 <= status_code < 200 or status_code == 204:
00166                 if content_length != 0:
00167                     warn(HTTPWarning('%r responses must have an empty '
00168                                      'content length') % status_code)
00169                 if bytes_sent:
00170                     warn(HTTPWarning('%r responses must not have a body' %
00171                                      status_code))
00172             elif content_length is not None and content_length != bytes_sent:
00173                 warn(WSGIWarning('Content-Length and the number of bytes '
00174                                  'sent to the client do not match.'))

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 133 of file lint.py.

00133 
00134     def next(self):
00135         if self.closed:
00136             warn(WSGIWarning('iterated over closed app_iter'),
00137                  stacklevel=2)
00138         rv = self._next()
00139         if not self.headers_set:
00140             warn(WSGIWarning('Application returned before it '
00141                              'started the response'), stacklevel=2)
00142         check_string('application iterator items', rv)
00143         self.chunks.append(len(rv))
00144         return rv

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 124 of file lint.py.

Definition at line 125 of file lint.py.

Definition at line 128 of file lint.py.

Definition at line 126 of file lint.py.

Definition at line 127 of file lint.py.


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