Package pyperry :: Module response :: Class Response
[frames] | no frames]

Class Response

source code

object --+
         |
        Response

Used to transport response data from a write adapter through the adapter's call stack.

A write adapter returns a Response object for all calls to its write or delete methods. The write adapter is responsible for setting the success, raw, raw_format, status, and meta attributes on the Response object, but should perform no additional processing. Middlewares can then use the response data to modify the model being saved. For example, after a write, one middleware may refresh the model's attributes, while another middleware may expire some cache entries for that model. The parsed, model_attributes, and errors methods are provided to return the response data in formats that are easy for middlewares to work with.

Instance Methods
 
__init__(self, **kwargs)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
parsed(self)
Returns a format-independent dictionary representation of the raw response data.
source code
 
model_attributes(self)
Returns a dictionary representing a model's attributes obtained by transforming the result of the parsed method.
source code
 
errors(self)
Returns a dictionary in the same format as the model's errors dictionary obtained by transforming the result of the parsed method.
source code
 
__setattr__(self, name, value)
Prevent the parsed method from being replaced.
source code

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

Class Variables
  PARSERS = {'json': <class 'pyperry.response_parsers.JSONRespon...
Instance Variables
  success
True if the write or delete succeeded, False otherwise
  status
an adapter-specific status code (optional)
  meta
adapter-specific information about the response (optional)
  raw
the raw (unmodified) response data received from the adapter
  raw_format
the data format of the raw response data, such as 'json' or 'xml'
Properties

Inherited from object: __class__

Method Details

__init__(self, **kwargs)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

parsed(self)

source code 

Returns a format-independent dictionary representation of the raw response data. Both the model_attributes and errors methods transform the result of the parsed method into a form that is meaningful.

__setattr__(self, name, value)

source code 

Prevent the parsed method from being replaced.

Allows a user to set response.parsed = {...} without replacing the parsed method. This is because the parsed method will parse the contents of the raw attribute and store its value in the _parsed attribute if _parsed has not already been set to some other value. Setting any other attribute still works like normal.

Overrides: object.__setattr__

Class Variable Details

PARSERS

Value:
{'json': <class 'pyperry.response_parsers.JSONResponseParser'>}