DLM consumes Tastypie

25 May 2012

Part of the JISC SuperOERGlue project is to pilot the integration of Tatemae's OER Glue with Dynamic Learning Maps (DLMs). So over the past week or so I have been investigating some concepts about how we could get OER Glue to 'talk to' DLMs and how best this could work. 

An obvious starting point seemed to be to build some kind of API which would allow this integration between the two systems.  Since this in itself is a big undertaking I decided to look into finding an existing solution which could be tailored to our needs.

After some searching I came across TastyPie which seemed an ideal solution since it was build on the Django framework which we used to build DLMs.  Out of the box Tastypie offers a powerful and highly customizable, abstraction for creating REST-style interfaces.  It also comes with some fairly comprehensive documentation and support which appealed to me - http://django-tastypie.readthedocs.org/en/latest/index.html


Setup Tastypie

To get started I followed the Installation section of the documentation site which runs though the basics of installing the app and using it within your Django application. Before I could get started I needed to have a number of dependencies included in my DLM app (listed in the installation guide), some we already had (such as Python and Django), others I needed to add.  The ones I needed to install all had easy_install available so it turned into a trivial task to get them set up.

Once the dependencies were available it was just a case of running:

easy_install django-tastypie

to install tastypie in my project.


Creating the API

Once installed I simply needed to create an api.py file (in my project) which I used to map my Django model to something Tastypie could use to create the API.  This was all explained in the documentation along with some examples but basically my code looked like this:

 class TopicResource(ModelResource):

    class Meta:

        queryset = Node.objects.all()

        resource_name = 'topic'

Finally I needed to update my urls file to tell it what url the api could be accessed from.  I went for the imaginative path /api/

Once complete I immediately had an API which outputted data in both json and xml format for entries in DLMs:;3/?format=xml


Future work

Of course having DLM data output from the API is only the first step and Tastypie offers a lot more functionality than this including:

Authentication / Authorization
Filtering & sorting

Which I plan to look into next.  I also haven't made an customisations to the code but I image this will come when I need to run searches for the API to output.

Related tags: oerri, rapid innovation, RIDLR, supoerglue, ukoer

Posted by: John Peterson

Posted in: OER rapid innovation: SupOERGlue, OER rapid innovation: RIDLR

MEDEV, School of Medical Sciences Education Development,
Faculty of Medical Sciences, Newcastle University, NE2 4HH