Managers are responsible for handling access
to the django models that you just created.
To start we are going to create a new file in
the todoapp called managers.py. After that
we are going to set up our managers.

fromdjango_ripozoimportDjangoManagerfrom.modelsimportTaskBoard,TaskclassTaskBoardManager(DjangoManager):# These are the default fields to use when performing any actionfields=('id','title','task_set.id',)update_fields=('title',)# These are the only fields allowed when updating.model=TaskBoardpaginate_by=10classTaskManager(DjangoManager):fields=('id','title','description','completed','task_board_id',)model=Taskpaginate_by=20

Resources are the core of ripozo. These are common
across all manager and dispatcher packages. This means,
assuming that the application was developed well, you could
reuse the resources in flask or mix them in with the sqlalchemy
manager.

The first thing we are going to do is create a file in the todoapp
directory called resources.py. Then we will add the following

fromripozoimportrestmixins,ListRelationship,Relationship,apimethodfrom.managersimportTaskBoardManager,TaskManagerclassTaskBoardResource(restmixins.CRUDL):manager=TaskBoardManager()resource_name='taskboard'pks=('id',)_relationships=(ListRelationship('task_set',relation='TaskResource'),)# We're going to add a simple way to add# tasks to a board by extending the@apimethod(route='/addtask',methods=['POST'])defadd_task(cls,request):body_args=request.body_argsbody_args['task_board_id']=request.get('id')request.body_args=body_argsreturnTaskResource.create(request)classTaskResource(restmixins.CRUD):manager=TaskManager()resource_name='task'pks=('id',)_relationships=(Relationship('task_board',property_map=dict(task_board_id='id'),relation='TaskBoardResource'),)

We now have a reusable core to our RESTful API. This is reusable across
various web frameworks, databases (you will have to change the manager),
or REST protocol.

The dispatcher is responsible for translating the
request into something that the framework (Django)
can understand and translating the ripozo response
into the frameworks preferred method. First create a urls.py file
in your todoapp directory. In that file:

>>> new_task=updated.add_task(title='My first task',description='I need to do something')>>> print(new_task.title)'My first task'>>> print(new_task.description)'I need to do something'>>> print(new_task.completed)False