[Mailman-Developers] GSOC 2013 : Authenticated REST-API in Postorius/Django

Florian Fuchs flo.fuchs at gmail.com
Tue Apr 9 00:17:54 CEST 2013


Hi Rahul,

2013/4/6 Rahul Gaur <rahul.nbg at gmail.com>
> So , last night I tried my hand on django-rest-framework [0]  and TastyPie
> [1] as well.
>
> What I could figure out with my two quick and dirty hands on applications
> of both the frameworks , the django-rest-framework is a bit more lengthy (
> but those few extra lines are for the best) when stacked up against
> Tastypie.
>
> I wrote this quick django app and then I tried to write API's for that app
> in both the framework.Both the frameworks have there own advantages lets
> talk about that.

Thanks for creating the two examples! I took a quick look at them and
it looks like both frameworks are pretty easy to use if a resource is
based on a typical Django model. The Mailman resources OTOH are not
retrieved from a database but from another API -- Mailman's core REST
API that is only served locally (postorius uses the mailman.client
library to access that data). Which of the two frameworks would you
consider more flexible if you want to get your data from anything else
but a Django DB model (I *think* Tastypie has different classes for
model resources and everythingelse-resources)?

> *$ curl http://127.0.0.1:8080/formpost/ -H 'Accept:text/html'
>
> The Django-rest-frameworks  API's returns web browsable representation of
> the data by default :)

Sounds nice! :-)

> So , the confusion I am facing here is that the Postorius is already mature
> and stable app and while playing with the two frameworks for API's  what I
> figured out is that if I opt for django-rest-framework , I would need to
> write new Views ?
> But if I go for TastyPie , I won't have to touch the existing Views and
> write authenticated API's.
>
> Hence to implement authenticated API's , which one would be better ?

Hard to say - judging by how they're used in the examples, both look
good. But there are some more things you might want to consider before
choosing one:

Authentication methods
Which auth methods are provided out of the box by the frameworks? And
which one(s) would you like to support (OAuth(2), BasicAuth over SSL,
...)? I guess choosing and implementing authentication could become
one of the major sub-tasks of that project.

Support for Django 1.5 and Python3:
At some point in the not so fare future mailman and postorius will be
ported to Python3. Django 1.5 already supports Python3, so it would be
a bonus point if the rest framework supports it, too (or if their
developers are making efforts to do so...).

Another idea (not sure if it's a good one): Maybe also take a closer
look at Django's class-based views. They are capable of routing
requests to the same URI to different dispatch methods, depending on
the HTTP method. So that might be also be an interesting option.

Cheers
Florian


More information about the Mailman-Developers mailing list