Package pulp :: Package server :: Package webservices :: Package controllers :: Module base :: Class JSONController
[hide private]
[frames] | no frames]

Class JSONController

source code

object --+
         |
        JSONController

Base controller class with convenience methods for JSON serialization

Instance Methods [hide private]
 
params(self)
JSON decode the objects in the requests body and return them
source code
 
filters(self, valid)
Fetch any parameters passed on the url
source code
 
filter_results(self, results, filters)
Returns: list of model instances that meat the criteria in the filters
source code
 
_output(self, data)
JSON encode the response and set the appropriate headers
source code
 
ok(self, data)
Return an ok response.
source code
 
created(self, location, data)
Return a created response.
source code
 
no_content(self) source code
 
bad_request(self, msg=None)
Return a not found error.
source code
 
unauthorized(self, msg=None) source code
 
not_found(self, msg=None)
Return a not found error.
source code
 
method_not_allowed(self, msg=None)
Return a method not allowed error.
source code
 
not_acceptable(self, msg=None)
Return a not acceptable error.
source code
 
conflict(self, msg=None)
Return a conflict error.
source code
 
internal_server_error(self, msg=None)
Return an internal server error.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Static Methods [hide private]
 
error_handler(method)
Static controller method wrapper that catches internal errors and reports them as JSON serialized trace back strings
source code
 
user_auth_required(roles=())
Static Controller method to check user permissions on web service calls
source code
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

params(self)

source code 

JSON decode the objects in the requests body and return them

Returns:
dict of parameters passed in through the body

filters(self, valid)

source code 

Fetch any parameters passed on the url

Parameters:
  • valid (list of str's) - list of expected query parameters
Returns:
dict of param: [value(s)] of uri query parameters

filter_results(self, results, filters)

source code 
Parameters:
  • results (iterable of pulp model instances) - results from a db query
  • filters (dict of str: list) - result filters passed in, in the uri
Returns:
list of model instances that meat the criteria in the filters

Deprecated: use mongo.filters_to_re_spec and pass the result into pulp's api instead

ok(self, data)

source code 

Return an ok response.

Parameters:
  • data (mapping type) - data to be returned in the body of the response
Returns:
JSON encoded response

created(self, location, data)

source code 

Return a created response.

Parameters:
  • location (str) - URL of the created resource
  • data (mapping type) - data to be returned in the body of the response
Returns:
JSON encoded response

bad_request(self, msg=None)

source code 

Return a not found error.

Parameters:
  • msg (str) - optional error message
Returns:
JSON encoded response

not_found(self, msg=None)

source code 

Return a not found error.

Parameters:
  • msg (str) - optional error message
Returns:
JSON encoded response

method_not_allowed(self, msg=None)

source code 

Return a method not allowed error.

Parameters:
  • msg (str) - optional error message
Returns:
JSON encoded response

not_acceptable(self, msg=None)

source code 

Return a not acceptable error.

Parameters:
  • msg (str) - optional error message
Returns:
JSON encoded response

conflict(self, msg=None)

source code 

Return a conflict error.

Parameters:
  • msg (str) - optional error message
Returns:
JSON encoded response

internal_server_error(self, msg=None)

source code 

Return an internal server error.

Parameters:
  • msg (str) - optional error message
Returns:
JSON encoded response