Package wtf :: Package impl :: Module _gateway :: Class ResponseStarter
[hide private]
[frames] | no frames]

Class ResponseStarter

source code

object --+
         |
        ResponseStarter

WSGI start_response callable with context
Instance Methods [hide private]
 
__init__(self, start_response)
Initialization
source code
callable
__call__(self, status, headers, exc_info=None)
Actual WSGI start_response function
source code
 
write_initial(self, data)
Initial write callable - raises an error
source code
 
write_headers(self, data, _do_init=False)
Secondary write callable - sends headers before real data
source code
 
write_body(self, data)
Final write callable
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables [hide private]
tuple _response = None
Status and headers supplied by the application
callable _start_response
Implementation defined response starter
file _stream = None
Response body stream
bool started = False
Flag indicating whether the response was started or not
callable write
Current write callable
Properties [hide private]
list headers
The response headers as supplied by the application
str status
The response status as supplied by the application

Inherited from object: __class__

Method Details [hide private]

__init__(self, start_response)
(Constructor)

source code 
Initialization
Parameters:
  • start_response (callable) - Implementation specific response starter; a callable, which takes status and headers and returns a body stream
Overrides: object.__init__

__call__(self, status, headers, exc_info=None)
(Call operator)

source code 
Actual WSGI start_response function
Parameters:
  • status (str) - Status line
  • headers (list) - Header list
  • exc_info (tuple) - Optional exception (output of sys.exc_info())
Returns: callable
Write callable (according to PEP 333)

write_initial(self, data)

source code 

Initial write callable - raises an error

If this method is called as .write, it generates an error, because the gateway was misused (__call__ not executed).

Parameters:
  • data (str) - The string to write
Raises:

write_headers(self, data, _do_init=False)

source code 

Secondary write callable - sends headers before real data

This write callable initializes the response on the first real occurence of data. The write method will be set directly to the stream's write method after response initialization.

Parameters:
  • data (str) - The data to write
  • _do_init (bool) - Initialize the headers anyway (regardless of data?)

write_body(self, data)

source code 

Final write callable

This adds a flush after every write call to the stream -- as required by the WSGI specification.

Parameters:
  • data (str) - The data to write

Property Details [hide private]

headers

The response headers as supplied by the application

Exceptions:
ResponseNotStarted : The response was not started yet
Get Method:
unreachable.fget(self)
Type:
list

status

The response status as supplied by the application

Exceptions:
ResponseNotStarted : The response was not started yet
Get Method:
unreachable.fget(self)
Type:
str