from pecan import expose

from mariner.models import Task
from mariner.controllers import error


class TaskController(object):

    def __init__(self, task_id):
        self.task = Task.query.filter_by(identifier=task_id).first()
        if not self.task:
            error('/errors/not_found/', '%s task was not found' % task_id)


class TasksController(object):

    @expose('json')
    def index(self):
        # TODO: allow some autodiscovery here so that clients can see what is
        # available
        return dict()

    @expose('json')
    def install(self):
        return {}

    @expose('json')
    def configure(self):
        return {}

    @expose()
    def _lookup(self, task_id, *remainder):
        return TaskController(task_id), remainder

@@ -412,117 +412,29 @@
     
-# TODO: allow some autodiscovery here so that clients can see what is%0A        # available%0A        return dict
+return Task.query.all
 ()%0A%0A

index on tasks should return all tasks" gst