SlideShare a Scribd company logo
1 of 50
Motion
              a               application

    Tonight’s presentation brought to you by
in association with The San Francisco Django Meetup Group
The Us
Ed Anuff            Martin Atkins

Leah Culver         Nima Badiey

Mike Malone         Chris Hall

Brad Choate
A Live Demo
Local DB

           Request Handler



         typepad-motion




                                                  Django
                                     Motion App
            typepadapp

        python-typepad-api

remoteobjects            batchhttp




                TypePad
Motion
Motion
It’s all BSD’d.
Feel free to utilize our teqniks
       (a.k.a. steal our code)
We        Feedback
But plz tell us if you
  make it better!
Things we wanted

• Easy to install
• Easy to extend
• Easy to integrate
Easy to install
$ easy_install -q typepad-motion
$ django-admin.py typepadproject mymotion 
> --settings=motion.settings
$ cat >> mymotion/local_settings.py
OAUTH_CONSUMER_KEY           = 'key'
OAUTH_CONSUMER_SECRET        = 'secret'
OAUTH_GENERAL_PURPOSE_KEY    = 'gp_key'
OAUTH_GENERAL_PURPOSE_SECRET = 'gp_secret'
$ cd mymotion
$ ./manage.py syncdb
$ ./manage.py runserver
Easy to install
• PyPi & pip (or setuptools or distribute) for
  package & dependency management
• Custom management commands
 • typepadproject
 • typepadapp
• Sane defaults
Management Commands
http://github.com/sixapart/typepadapp/blob/master/typepadapp/management/commands/typepadproject.py
Easy to extend
$ ./manage.py typepadapp myapp
Base Templates
                   $ cat motion/templates/motion/events.html
                   {% extends "motion/base/events.html" %}
                   $




http://github.com/sixapart/typepad-motion/tree/master/motion/templates/motion/
Template Caching
                   http://code.djangoproject.com/ticket/6262
http://github.com/sixapart/typepadapp/blob/master/typepadapp/cached_templates.py
Class-based Views
http://github.com/sixapart/typepadapp/blob/master/typepadapp/views/base.py#L61
Easy to integrate
It’s just a Django app. Not much more to say.
Replaced auth.models.User
http://github.com/sixapart/typepadapp/blob/master/typepadapp/models/users.py#L47

 http://github.com/sixapart/typepadapp/blob/master/typepadapp/backends.py#L41
Below the
httplib2
• Developed by Joe Gregorio
• Sports a number of features that are useful
  for talking to web services
  • Caching
  • Compression
  • Extensible authentication mechanism
OAuth & httplib2
http://github.com/sixapart/python-typepad-api/blob/master/typepad/oauthclient.py#L106
OAuth & httplib2
>>> import oauthclient
>>> from oauth import oauth
>>> consumer = oauth.OAuthConsumer('key', 'secret')
>>> token = oauth.OAuthToken('key', 'secret')
>>> client = oauthclient.OAuthHttp()
>>> client.add_credentials(consumer, token, 'twitter.com')
>>> client.request(
        'http://twitter.com/account/verify_credentials.json')
... THE RESPONSE ...
remoteobjects
•   We work a lot with RESTish web services at Six Apart

•   Mark Paschal (@markpasc) created an abstraction layer
    that allows us to create robust client libraries very
    easily

    •   The remoteobjects library allows you to describe an
        API using a declarative syntax, like Django models

    •   Works very well with RESTful APIs, but it’s generic
        enough to work with RPC APIs too
remoteobjects
class User(RemoteObject):
  id = fields.Field()
  name = fields.Field()
  screen_name = fields.Field()
  [ ... ]
  followers_count = fields.Field()
  status = fields.Object(‘status’)

  @classmethod
  def get_user(cls, http=None, **kwargs):
    url = ‘/usrs/show’
    if ‘id’ in kwargs:
      url += ‘/%s.json’ % quote_plus(kwargs.pop(‘id’))
    else:
      url += ‘.json’
    query = urlencode(kwargs)
    url = urlunsplit((None, None, url, query, None))
    return cls.get(urljoin(Twitter.endpoint, url),
                   http=http)
remoteobjects
>>> t = twitter.Twitter()
>>> t.add_credentials('mjmalone', 'thisisnotmypassword')
>>> friends_timeline = t.friends_timeline()
>>> [e.user.screen_name for e in friends.entries]
['ronaldheft', 'joestump', 'donttrythis',
'laughingsquid', 'FrankGruber', 'courtstarr', 'mbaratz',
'djchall', 'dozba', 'chrismessina', 'pop17', 'ijustine',
'calden', 'bryanveloso', 'jessenoller', 'pierre',
'optimarcusprime', 'snackfight', 'shiralazar']
remoteobjects
http://github.com/sixapart/remoteobjects
Batch HTTP
What?


• A mechanism for retrieving several distinct
  resources in a single HTTP request.
TypePad API URLs

• The TypePad API is a REST API
• Each distinct resource has its own URL
  which supports some subset of the
  operations GET, PUT, POST and DELETE.
TypePad API URLs
TypePad API URLs
/users/apparentlymart



 noun


             id
TypePad API URLs
/users/apparentlymart/relationships



 noun


              id
                       sub-resource
TypePad API URLs
/users/apparentlymart/relationships/@by-group/6p1234123412341234



 noun


            id
                     sub-resource

                                          parameterized
                                              filter
TypePad API URLs
/users/apparentlymart/relationships/@following



 noun


             id
                      sub-resource

                                     boolean
                                      filter
Motion’s Home Page

           All of the data here
            comes from the
               TypePad API
Motion’s Home Page
                        /users/apparentlymart




                                                 /users/apparentlymart/relationships/@following
                                                 /users/apparentlymart/relationships/@follower




                                                 Requires 5 resources
                                                 from api.typepad.com
/groups/{id}/events   /groups/{id}/memberships
How can we retrieve
   those five resource
from TypePad as quickly
    and efficiently as
        possible?
Design Goals
• Retrieve all required resources in parallel
• Allow TypePad to optimize the multi-get to
  return a response as quickly as possible
• Be consistent with how single resources
  are returned in the normal case
• Invent as little as possible
Parallel HTTP Requests
• Reasonably easy from the client’s
  perspective, assuming that their HTTP
  client library doesn’t suck.
• Difficult to optimize predictably on
  TypePad’s end because we can’t control the
  order and timing of the handling of
  individual requests.
HTTP Pipelining

• Poor support from libraries and
  infrastructure.
• Responses must be returned in order of
  request, which complicates the API
  dispatcher.
Batch Processing API
Batch Processing API
                     Client




               Batch Processor




      API Endpoint            API Endpoint
Batch Processing API

• GData (ab?)uses Atom to define a list of
  operations.
• AWS uses some AWS-specific query string
  arguments or SOAP-ish stuff.
• Ideally we wanted batch processing to be
  an orthogonal layer.
Batch Processing API


• Long story short: we designed a batch
  processing mechanism that can hopefully
  apply to any REST-based API.
Batch Processing API
• Batch Processor is conceptually similar to
  an HTTP proxy.
• The frontend accepts a POST request
  containing a MIME multipart message
  containing a bunch of requests, and returns
  a multipart message containing the
  corresponding response.
Batch Processing API
• Conceptually, the backend of the batch
  processor makes its own HTTP requests to
  the indicated resources like an HTTP proxy
  would.
• In practice, TypePad’s implementation
  handles the entire batch job together and
  fakes up the separate responses.
Batch Processing API

• We’ve published a spec and some open
  source sample implementations in the hope
  that it’s useful to the community:
  http://martin.atkins.me.uk/specs/batchhttp
  http://github.com/sixapart/batchhttp
  http://github.com/sixapart/libhttp-request-multi-perl
Python Batch Request
def callback(url, subresponse, subcontent):
    self.subresponse = subresponse
    self.subcontent = subcontent

client = BatchClient(endpoint=
                     'http://127.0.0.1:8000/batch-processor')

client.batch_request()
client.batch({'uri': 'http://example.com/moose'},
             callback=callback)
client.batch({'uri': 'http://example.com/mouse'},
             callback=callback)
client.complete_batch()
That’s All!
      http://developer.typepad.com/
http://github.com/sixapart/typepad-motion/


          Questions?

More Related Content

What's hot

Using Sinatra to Build REST APIs in Ruby
Using Sinatra to Build REST APIs in RubyUsing Sinatra to Build REST APIs in Ruby
Using Sinatra to Build REST APIs in RubyLaunchAny
 
Building Better Web APIs with Rails
Building Better Web APIs with RailsBuilding Better Web APIs with Rails
Building Better Web APIs with RailsAll Things Open
 
Refactor Dance - Puppet Labs 'Best Practices'
Refactor Dance - Puppet Labs 'Best Practices'Refactor Dance - Puppet Labs 'Best Practices'
Refactor Dance - Puppet Labs 'Best Practices'Gary Larizza
 
Building Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET CoreBuilding Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET CoreNate Barbettini
 
Building Beautiful REST APIs with ASP.NET Core
Building Beautiful REST APIs with ASP.NET CoreBuilding Beautiful REST APIs with ASP.NET Core
Building Beautiful REST APIs with ASP.NET CoreStormpath
 
Pourquoi ruby et rails déchirent
Pourquoi ruby et rails déchirentPourquoi ruby et rails déchirent
Pourquoi ruby et rails déchirentNicolas Ledez
 
Spl to the Rescue - Zendcon 09
Spl to the Rescue - Zendcon 09Spl to the Rescue - Zendcon 09
Spl to the Rescue - Zendcon 09Elizabeth Smith
 
Graphql + Symfony | Александр Демченко | CODEiD
Graphql + Symfony | Александр Демченко | CODEiDGraphql + Symfony | Александр Демченко | CODEiD
Graphql + Symfony | Александр Демченко | CODEiDCODEiD PHP Community
 
memories of tumblr gear & Tumblrowl
memories of tumblr gear & Tumblrowlmemories of tumblr gear & Tumblrowl
memories of tumblr gear & Tumblrowlhonishi
 
Layouts and Rendering in Rails, Season 2
Layouts and Rendering in Rails, Season 2Layouts and Rendering in Rails, Season 2
Layouts and Rendering in Rails, Season 2RORLAB
 
Build and maintain large ruby applications Ruby Conf Australia 2016
Build and maintain large ruby applications Ruby Conf Australia 2016Build and maintain large ruby applications Ruby Conf Australia 2016
Build and maintain large ruby applications Ruby Conf Australia 2016Enrico Teotti
 
Memory Management In Python The Basics
Memory Management In Python The BasicsMemory Management In Python The Basics
Memory Management In Python The BasicsNina Zakharenko
 
Elegant Solutions For Everyday Python Problems - Nina Zakharenko
Elegant Solutions For Everyday Python Problems - Nina ZakharenkoElegant Solutions For Everyday Python Problems - Nina Zakharenko
Elegant Solutions For Everyday Python Problems - Nina ZakharenkoNina Zakharenko
 
With a Mighty Hammer
With a Mighty HammerWith a Mighty Hammer
With a Mighty HammerBen Scofield
 
Gaelyk: Lightweight Groovy on the Google App Engine
Gaelyk: Lightweight Groovy on the Google App EngineGaelyk: Lightweight Groovy on the Google App Engine
Gaelyk: Lightweight Groovy on the Google App EngineTim Berglund
 
REST API Best Practices & Implementing in Codeigniter
REST API Best Practices & Implementing in CodeigniterREST API Best Practices & Implementing in Codeigniter
REST API Best Practices & Implementing in CodeigniterSachin G Kulkarni
 
Action Controller Overview, Season 2
Action Controller Overview, Season 2Action Controller Overview, Season 2
Action Controller Overview, Season 2RORLAB
 
Sinatra Rack And Middleware
Sinatra Rack And MiddlewareSinatra Rack And Middleware
Sinatra Rack And MiddlewareBen Schwarz
 

What's hot (20)

Using Sinatra to Build REST APIs in Ruby
Using Sinatra to Build REST APIs in RubyUsing Sinatra to Build REST APIs in Ruby
Using Sinatra to Build REST APIs in Ruby
 
Building Better Web APIs with Rails
Building Better Web APIs with RailsBuilding Better Web APIs with Rails
Building Better Web APIs with Rails
 
Refactor Dance - Puppet Labs 'Best Practices'
Refactor Dance - Puppet Labs 'Best Practices'Refactor Dance - Puppet Labs 'Best Practices'
Refactor Dance - Puppet Labs 'Best Practices'
 
Building Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET CoreBuilding Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET Core
 
Building Beautiful REST APIs with ASP.NET Core
Building Beautiful REST APIs with ASP.NET CoreBuilding Beautiful REST APIs with ASP.NET Core
Building Beautiful REST APIs with ASP.NET Core
 
Pourquoi ruby et rails déchirent
Pourquoi ruby et rails déchirentPourquoi ruby et rails déchirent
Pourquoi ruby et rails déchirent
 
Spl to the Rescue - Zendcon 09
Spl to the Rescue - Zendcon 09Spl to the Rescue - Zendcon 09
Spl to the Rescue - Zendcon 09
 
Symfony + GraphQL
Symfony + GraphQLSymfony + GraphQL
Symfony + GraphQL
 
Graphql + Symfony | Александр Демченко | CODEiD
Graphql + Symfony | Александр Демченко | CODEiDGraphql + Symfony | Александр Демченко | CODEiD
Graphql + Symfony | Александр Демченко | CODEiD
 
memories of tumblr gear & Tumblrowl
memories of tumblr gear & Tumblrowlmemories of tumblr gear & Tumblrowl
memories of tumblr gear & Tumblrowl
 
Layouts and Rendering in Rails, Season 2
Layouts and Rendering in Rails, Season 2Layouts and Rendering in Rails, Season 2
Layouts and Rendering in Rails, Season 2
 
Build and maintain large ruby applications Ruby Conf Australia 2016
Build and maintain large ruby applications Ruby Conf Australia 2016Build and maintain large ruby applications Ruby Conf Australia 2016
Build and maintain large ruby applications Ruby Conf Australia 2016
 
Memory Management In Python The Basics
Memory Management In Python The BasicsMemory Management In Python The Basics
Memory Management In Python The Basics
 
Elegant Solutions For Everyday Python Problems - Nina Zakharenko
Elegant Solutions For Everyday Python Problems - Nina ZakharenkoElegant Solutions For Everyday Python Problems - Nina Zakharenko
Elegant Solutions For Everyday Python Problems - Nina Zakharenko
 
With a Mighty Hammer
With a Mighty HammerWith a Mighty Hammer
With a Mighty Hammer
 
Gaelyk: Lightweight Groovy on the Google App Engine
Gaelyk: Lightweight Groovy on the Google App EngineGaelyk: Lightweight Groovy on the Google App Engine
Gaelyk: Lightweight Groovy on the Google App Engine
 
REST API Best Practices & Implementing in Codeigniter
REST API Best Practices & Implementing in CodeigniterREST API Best Practices & Implementing in Codeigniter
REST API Best Practices & Implementing in Codeigniter
 
Action Controller Overview, Season 2
Action Controller Overview, Season 2Action Controller Overview, Season 2
Action Controller Overview, Season 2
 
Sinatra Rack And Middleware
Sinatra Rack And MiddlewareSinatra Rack And Middleware
Sinatra Rack And Middleware
 
Modern Perl
Modern PerlModern Perl
Modern Perl
 

Viewers also liked (20)

Marketing Digital
Marketing DigitalMarketing Digital
Marketing Digital
 
¿Qué es la Facioterapia?
¿Qué es la Facioterapia?¿Qué es la Facioterapia?
¿Qué es la Facioterapia?
 
2911 1 3
2911 1 32911 1 3
2911 1 3
 
Manual magento 1-1
Manual magento 1-1Manual magento 1-1
Manual magento 1-1
 
Norwich o crest_bred
Norwich o crest_bredNorwich o crest_bred
Norwich o crest_bred
 
Digital Influence - The social professional
Digital Influence - The social professionalDigital Influence - The social professional
Digital Influence - The social professional
 
From SQL to MongoDB
From SQL to MongoDBFrom SQL to MongoDB
From SQL to MongoDB
 
Actitud Laboral
Actitud LaboralActitud Laboral
Actitud Laboral
 
La Diaclasa (Benaocaz)
La Diaclasa  (Benaocaz)La Diaclasa  (Benaocaz)
La Diaclasa (Benaocaz)
 
RAF TABTRONICS LLC COMPANY OVERVIEW - 2014
RAF TABTRONICS LLC COMPANY OVERVIEW - 2014RAF TABTRONICS LLC COMPANY OVERVIEW - 2014
RAF TABTRONICS LLC COMPANY OVERVIEW - 2014
 
IVA CAIXA
IVA CAIXAIVA CAIXA
IVA CAIXA
 
Presentación Internet_ruben diaz
Presentación Internet_ruben diaz Presentación Internet_ruben diaz
Presentación Internet_ruben diaz
 
Literatura guatemalteca de finales del siglo XIX
Literatura guatemalteca de finales del siglo XIXLiteratura guatemalteca de finales del siglo XIX
Literatura guatemalteca de finales del siglo XIX
 
Curso inicial
Curso inicialCurso inicial
Curso inicial
 
Procesos mc perú
Procesos mc perúProcesos mc perú
Procesos mc perú
 
Artseduca 7
Artseduca 7Artseduca 7
Artseduca 7
 
Psicologia+clinica+que+es
Psicologia+clinica+que+esPsicologia+clinica+que+es
Psicologia+clinica+que+es
 
Exercici portfolio
Exercici portfolioExercici portfolio
Exercici portfolio
 
PROGRAMA ERRADICACION DE LA MOSCA DEL MEDITERRANEO EN MENDOZA
PROGRAMA ERRADICACION DE LA MOSCA DEL MEDITERRANEO EN MENDOZAPROGRAMA ERRADICACION DE LA MOSCA DEL MEDITERRANEO EN MENDOZA
PROGRAMA ERRADICACION DE LA MOSCA DEL MEDITERRANEO EN MENDOZA
 
Contraste
ContrasteContraste
Contraste
 

Similar to Motion Django Meetup

Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformAntonio Peric-Mazar
 
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileIVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileAmazon Web Services Japan
 
Designing and Implementing a Multiuser Apps Platform
Designing and Implementing a Multiuser Apps PlatformDesigning and Implementing a Multiuser Apps Platform
Designing and Implementing a Multiuser Apps PlatformApigee | Google Cloud
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformAntonio Peric-Mazar
 
Python & Django TTT
Python & Django TTTPython & Django TTT
Python & Django TTTkevinvw
 
Sinatra and JSONQuery Web Service
Sinatra and JSONQuery Web ServiceSinatra and JSONQuery Web Service
Sinatra and JSONQuery Web Servicevvatikiotis
 
Developing Brilliant and Powerful APIs in Ruby & Python
Developing Brilliant and Powerful APIs in Ruby & PythonDeveloping Brilliant and Powerful APIs in Ruby & Python
Developing Brilliant and Powerful APIs in Ruby & PythonSmartBear
 
How to Contribute to Apache Usergrid
How to Contribute to Apache UsergridHow to Contribute to Apache Usergrid
How to Contribute to Apache UsergridDavid M. Johnson
 
High quality ap is with api platform
High quality ap is with api platformHigh quality ap is with api platform
High quality ap is with api platformNelson Kopliku
 
Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)Tim Burks
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesciklum_ods
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developersPatrick Savalle
 
Creating PostgreSQL-as-a-Service at Scale
Creating PostgreSQL-as-a-Service at ScaleCreating PostgreSQL-as-a-Service at Scale
Creating PostgreSQL-as-a-Service at ScaleSean Chittenden
 
Python tools for testing web services over HTTP
Python tools for testing web services over HTTPPython tools for testing web services over HTTP
Python tools for testing web services over HTTPMykhailo Kolesnyk
 
Slicing, Dicing, And Linting OpenAPI
Slicing, Dicing, And Linting OpenAPISlicing, Dicing, And Linting OpenAPI
Slicing, Dicing, And Linting OpenAPIlestrrat
 
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram VaswaniCreating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswanivvaswani
 

Similar to Motion Django Meetup (20)

Bpstudy20101221
Bpstudy20101221Bpstudy20101221
Bpstudy20101221
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
 
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileIVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
 
Api
ApiApi
Api
 
Designing and Implementing a Multiuser Apps Platform
Designing and Implementing a Multiuser Apps PlatformDesigning and Implementing a Multiuser Apps Platform
Designing and Implementing a Multiuser Apps Platform
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
 
Python & Django TTT
Python & Django TTTPython & Django TTT
Python & Django TTT
 
Sinatra and JSONQuery Web Service
Sinatra and JSONQuery Web ServiceSinatra and JSONQuery Web Service
Sinatra and JSONQuery Web Service
 
Developing Brilliant and Powerful APIs in Ruby & Python
Developing Brilliant and Powerful APIs in Ruby & PythonDeveloping Brilliant and Powerful APIs in Ruby & Python
Developing Brilliant and Powerful APIs in Ruby & Python
 
Crafting APIs
Crafting APIsCrafting APIs
Crafting APIs
 
How to Contribute to Apache Usergrid
How to Contribute to Apache UsergridHow to Contribute to Apache Usergrid
How to Contribute to Apache Usergrid
 
High quality ap is with api platform
High quality ap is with api platformHigh quality ap is with api platform
High quality ap is with api platform
 
Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devices
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developers
 
Creating PostgreSQL-as-a-Service at Scale
Creating PostgreSQL-as-a-Service at ScaleCreating PostgreSQL-as-a-Service at Scale
Creating PostgreSQL-as-a-Service at Scale
 
REST easy with API Platform
REST easy with API PlatformREST easy with API Platform
REST easy with API Platform
 
Python tools for testing web services over HTTP
Python tools for testing web services over HTTPPython tools for testing web services over HTTP
Python tools for testing web services over HTTP
 
Slicing, Dicing, And Linting OpenAPI
Slicing, Dicing, And Linting OpenAPISlicing, Dicing, And Linting OpenAPI
Slicing, Dicing, And Linting OpenAPI
 
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram VaswaniCreating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
 

Recently uploaded

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Motion Django Meetup

Editor's Notes

  1. - The bottom layer is remoteobjects & batchhttp, we’ll talk about those later. - The Python TypePad API library is a pure Python client library for talking to the TypePad API - typepadapp is a Django application that provides basic functionality that’s generally useful for Django apps built on top of TypePad like user authentication, OAuth token management, session management, and session synchronization - typepad-motion is really just a thin layer on top of these building blocks - it’s a set of views, URLConfs, templates, and some static resources like CSS, images, and javascript
  2. So, to simplify things to a stupid degree, the Motion architecture looks something like this.
  3. PyPi, pip, distribute, setuptools, etc. help a lot. We could decompose Motion into separate apps and maintain a good design, but still make it really easy to install. It also let us leverage outside code like httplib2 without having to include all of that stuff in our distributions. We’re using a custom management command to install our own skeleton files for a typepad project. You don’t have to use it, but it will set up sane defaults for all the Motion settings. Obscure settings are in motion.settings, so our default settings.py imports * from there.
  4. Turns out Django’s Management commands in Django really easily. Django iterates over your installed apps and looks in management/commands/<commandname>.py for a class called Command that subclasses management.base.BaseCommand. So once you have a project it’s easy to add commands. It’s a bit trickier for django-admin.py because you don’t have any installed apps by default. But you can specify a settings file to django-admin.py and it’ll load those settings before it tries to find the command. Score!
  5. Automatically creates directory structure for theming & static resources, creates urlpattern for static media. Stupid Django 1.1.1 “security patch” broke this stuff though, fixed in Motion trunk, but not in the PyPi version.
  6. All of our templates just extend motion/base/<template>.html. Thus, you can create a template _with the same name_, also extend motion/base/<template>.html, and override specific blocks. This is basically an alternative to letting you create templates that have different names and then pass them in as kwargs in your urls.py.
  7. We decomposed our templates a lot to make them more extensible. Problem is, whenever a template is rendered Django has to read it from disk, lex it, parse it, and then render it. It doesn’t do any caching. This was taking around 1ms per template. We were rendering hundreds of templates. It adds up.
  8. All Django requires for a “view” function is a “callable” that returns an HttpResponse. You can use a function to do this, but you can also use classes. We decided to use classes so we could provide hooks that make it easier to extend Motion - like batch HTTP stuff.
  9. Here’s an example of a RemoteObject class representing a Twitter user. The code for this comes with the remoteobjects package, by the way. There are a number of other examples that come with the package as well.
  10. - For context I’ll just summarize the resource model for the TypePad API
  11. Data API URLs always start with a noun and an id A bare URL like this retrieves a single object
  12. A third path level selects a sub-resource of a top-level object Many of these are lists
  13. List resources tend to support filters which constrain what items are returned. There are both parameterized filters...
  14. ...and boolean filters. and in some cases multiple filters can be combined together.
  15. Every page in Motion is constructed predominently from data retrieved from TypePad via the API.
  16. We need to get all of the required data out of TypePad as quickly as possible.
  17. At first, we just used parallel HTTP requests, which is pretty straightforward. This proved inefficient within TypePad’s infrastructure since we ended up with each request in its own Apache process. While other architectures are possible, completely reinventing our stack would be time-consuming.
  18. We briefly considered HTTP Pipelining as a purist solution, but in practice we found various problems. - Poor client library support - Poor infrastructure support (our load balancers don’t support pipelining) - Implementation would’ve been complicated due to having to maintain the request order.
  19. We eventually settled on having a special endpoint for submitting batch requests.
  20. The client submits a single request to the batch processor which contains a description of all of the constituent requests. The individual requests get handled, and are returned together as a single HTTP response. But we need to figure out what a description of a batch job looks like on the wire...
  21. We looked at some prior art here, but everything seemed to be specific to the API it was wrapping. Figuring that batch processing ought to be transparent, we wanted something that could exist as a separate infrastructure layer.
  22. Think of it as an HTTP proxy with a funny-looking frontend. We use a multipart MIME message with each part containing a HTTP message as our wire format. This allows HTTP messages to be wrapped with minimal overhead.
  23. Although our internal implementation actually does something more clever, the protocol presents the illusion that each request is being handled independently as if it were a proxied request to a data endpoint.
  24. We think this approach ought to work for other REST-based APIs, so we made a point of keeping it generic and we’ve released a draft specification and some sample implementations, including a Python client library which works with httplib2 and a Twisted-based proxy that can be used to put a batch processor frontend in front of some existing endpoints.