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

Class AsyncController

source code

    object --+    
             |    
JSONController --+
                 |
                AsyncController

Base controller class with convenience methods for executing asynchronous tasks.

Instance Methods [hide private]
 
_task_to_dict(self, task)
Convert a task to a dictionary (non-destructive) while retaining the pertinent information for a status check but in a more convenient form for JSON serialization.
source code
 
_status_path(self, id)
Construct a URL path that can be used to poll a task's status A status path is constructed as follows: /<collection>/<object id>/<action>/<action id>/ A GET request sent to this path will get a JSON encoded status object
source code
 
start_task(self, func, args=[], kwargs={}, timeout=None, unique=False)
Execute the function and its arguments as an asynchronous task.
source code
 
cancel_task(self, task)
Cancel the passed in task
source code
 
task_status(self, id)
Get the current status of an asynchronous task.
source code
 
find_task(self, id)
Find and return a task with the given id
source code
 
timeout(self, data)
Parse any timeout values out of the passed in data
source code
 
accepted(self, status)
Return an accepted response with status information in the body.
source code

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

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

_task_to_dict(self, task)

source code 

Convert a task to a dictionary (non-destructive) while retaining the pertinent information for a status check but in a more convenient form for JSON serialization.

Parameters:
  • task (Task instance) - task to convert @return dict representing task

start_task(self, func, args=[], kwargs={}, timeout=None, unique=False)

source code 

Execute the function and its arguments as an asynchronous task.

Parameters:
  • func - python callable
  • args - positional arguments for func
  • kwargs - key word arguments for func
Returns:
dict representing the task

cancel_task(self, task)

source code 

Cancel the passed in task

Parameters:
  • task (Task instance) - task to cancel
Returns:
True if the task was successfully canceled, False otherwise

task_status(self, id)

source code 

Get the current status of an asynchronous task.

Parameters:
  • id - task id
Returns:
TaskModel instance

find_task(self, id)

source code 

Find and return a task with the given id

Parameters:
  • id (str) - id of task to find
Returns:
Task instance if a task with the id exists, None otherwise

timeout(self, data)

source code 

Parse any timeout values out of the passed in data

Parameters:
  • data (dict) - values passed in via a request body
Returns:
datetime.timedelta instance corresponding to a properly formatted timeout value if found in data, None otherwise

accepted(self, status)

source code 

Return an accepted response with status information in the body.

Returns:
JSON encoded response