Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Jason - Django-like Object Mapper for REST serv...

Jason - Django-like Object Mapper for REST services

Avatar for Paris Kasidiaris

Paris Kasidiaris

October 27, 2014
Tweet

More Decks by Paris Kasidiaris

Other Decks in Programming

Transcript

  1. Introduction •  I am Paris •  Founder at sourcelair.com – Lets

    you code your projects in a browser •  I We love REST services
  2. Our architecture SourceLair web client SourceLair API SourceLair web API

    Supportive software (Monitoring service, internal analytics etc.) 3rd party REST services
  3. The problem •  We consume multiple REST services – SourceLair API

    – GitHub API – (more to come) •  Multiple code patterns – While we need similar semantics – (We despise for code style fragmentation)
  4. Setting up a service import jason my_service = jason.Service(host=‘myservice.com’, root=‘api’)

    class User(my_service.Resource): created = jason.fields.DateTimeField() username = jason.fields.StringField() # Get all users users = User.objects.all() # Parses “GET http://myservice.com/api/users”
  5. Querying the SourceLair API from datetime import datetime from sourcelair.api.models

    import User this_month = datetime(year=2014, month=10) new_users = User.objects.filter(created__gte=this_month) for new_user in new_users: print new_user.username
  6. Querying the GitHub API from github.models import GitHubUser parisk =

    GitHubUser.objects.get(login=‘parisk’) for repo in parisk.Repo.objects.filter(sort=‘created’): print repo.name, repo.url
  7. Jason is in Alpha stage •  Do not use in

    production – Try it at home though ;) •  You are welcome to contribute code – or contribute by filing issues