Back to index

moin  1.9.0~rc2
Public Member Functions | Private Member Functions | Private Attributes
MoinMoin.support.flup.server.fcgi_base.InputStream Class Reference
Inheritance diagram for MoinMoin.support.flup.server.fcgi_base.InputStream:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __init__
def read
def readline
def readlines
def __iter__
def next
def add_data

Private Member Functions

def _shrinkBuffer
def _waitForData

Private Attributes

 _conn
 _shrinkThreshold
 _buf
 _bufList
 _pos
 _avail
 _eof

Detailed Description

File-like object representing FastCGI input streams (FCGI_STDIN and
FCGI_DATA). Supports the minimum methods required by WSGI spec.

Definition at line 118 of file fcgi_base.py.


Constructor & Destructor Documentation

Reimplemented in MoinMoin.support.flup.server.fcgi_base.MultiplexedInputStream.

Definition at line 123 of file fcgi_base.py.

00123 
00124     def __init__(self, conn):
00125         self._conn = conn
00126 
00127         # See Server.
00128         self._shrinkThreshold = conn.server.inputStreamShrinkThreshold
00129 
00130         self._buf = ''
00131         self._bufList = []
00132         self._pos = 0 # Current read position.
00133         self._avail = 0 # Number of bytes currently available.
00134 
00135         self._eof = False # True when server has sent EOF notification.


Member Function Documentation

Definition at line 218 of file fcgi_base.py.

00218 
00219     def __iter__(self):
00220         return self

Gets rid of already read data (since we can't rewind).

Definition at line 136 of file fcgi_base.py.

00136 
00137     def _shrinkBuffer(self):
00138         """Gets rid of already read data (since we can't rewind)."""
00139         if self._pos >= self._shrinkThreshold:
00140             self._buf = self._buf[self._pos:]
00141             self._avail -= self._pos
00142             self._pos = 0
00143 
00144             assert self._avail >= 0

Here is the caller graph for this function:

Waits for more data to become available.

Reimplemented in MoinMoin.support.flup.server.fcgi_base.MultiplexedInputStream.

Definition at line 145 of file fcgi_base.py.

00145 
00146     def _waitForData(self):
00147         """Waits for more data to become available."""
00148         self._conn.process_input()

Here is the caller graph for this function:

Reimplemented in MoinMoin.support.flup.server.fcgi_base.MultiplexedInputStream.

Definition at line 227 of file fcgi_base.py.

00227 
00228     def add_data(self, data):
00229         if not data:
00230             self._eof = True
00231         else:
00232             self._bufList.append(data)
00233             self._avail += len(data)

Definition at line 221 of file fcgi_base.py.

00221 
00222     def next(self):
00223         r = self.readline()
00224         if not r:
00225             raise StopIteration
00226         return r

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented in MoinMoin.support.flup.server.fcgi_base.MultiplexedInputStream.

Definition at line 149 of file fcgi_base.py.

00149 
00150     def read(self, n=-1):
00151         if self._pos == self._avail and self._eof:
00152             return ''
00153         while True:
00154             if n < 0 or (self._avail - self._pos) < n:
00155                 # Not enough data available.
00156                 if self._eof:
00157                     # And there's no more coming.
00158                     newPos = self._avail
00159                     break
00160                 else:
00161                     # Wait for more data.
00162                     self._waitForData()
00163                     continue
00164             else:
00165                 newPos = self._pos + n
00166                 break
00167         # Merge buffer list, if necessary.
00168         if self._bufList:
00169             self._buf += ''.join(self._bufList)
00170             self._bufList = []
00171         r = self._buf[self._pos:newPos]
00172         self._pos = newPos
00173         self._shrinkBuffer()
00174         return r

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented in MoinMoin.support.flup.server.fcgi_base.MultiplexedInputStream.

Definition at line 175 of file fcgi_base.py.

00175 
00176     def readline(self, length=None):
00177         if self._pos == self._avail and self._eof:
00178             return ''
00179         while True:
00180             # Unfortunately, we need to merge the buffer list early.
00181             if self._bufList:
00182                 self._buf += ''.join(self._bufList)
00183                 self._bufList = []
00184             # Find newline.
00185             i = self._buf.find('\n', self._pos)
00186             if i < 0:
00187                 # Not found?
00188                 if self._eof:
00189                     # No more data coming.
00190                     newPos = self._avail
00191                     break
00192                 else:
00193                     if length is not None and len(self._buf) >= length + self._pos:
00194                         newPos = self._pos + length
00195                         break
00196                     # Wait for more to come.
00197                     self._waitForData()
00198                     continue
00199             else:
00200                 newPos = i + 1
00201                 break
00202         r = self._buf[self._pos:newPos]
00203         self._pos = newPos
00204         self._shrinkBuffer()
00205         return r

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 206 of file fcgi_base.py.

00206 
00207     def readlines(self, sizehint=0):
00208         total = 0
00209         lines = []
00210         line = self.readline()
00211         while line:
00212             lines.append(line)
00213             total += len(line)
00214             if 0 < sizehint <= total:
00215                 break
00216             line = self.readline()
00217         return lines

Here is the call graph for this function:


Member Data Documentation

Definition at line 132 of file fcgi_base.py.

Definition at line 129 of file fcgi_base.py.

Definition at line 130 of file fcgi_base.py.

Definition at line 124 of file fcgi_base.py.

Definition at line 134 of file fcgi_base.py.

Definition at line 131 of file fcgi_base.py.

Definition at line 127 of file fcgi_base.py.


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