SlideShare una empresa de Scribd logo
1 de 67
Descargar para leer sin conexión
Pluggable Patterns
  For Reusable Django Applications
Project
Project




Configuration   URL routing   Templates
Project
 Application    Application   Application




 Application    Application   Application




 Application    Application   Application



Configuration   URL routing   Templates
Here there be power!
                  Project
 Application      Application   Application




 Application      Application   Application




 Application      Application   Application



Configuration     URL routing   Templates
We need a better definition
 for “Django Application”
An app                          MyBlog App
should not be              • Categories
                           • Custom Tagging
a monolithic               • Custom Comments
pile of code               • Comment
                             Moderation
                           • Assumption of text
                             markup type
                           • Single blogs
For example, most blog     • Multiple Sites
“apps” available provide
too much functionality           ACME MONOLITHS
An application should
   be “pluggable”
A “pluggable” app is
      Focused
Write programs that do one thing and do it well.
   — Doug McIlroy (inventor of UNIX pipes)
A “pluggable” app is
   Self-Contained
      Batteries are included
    Dependencies are declared
A “pluggable” app is
    Easily Adaptable
Corey’s Law: The less adaptable you make your code, the
          sooner you will be tasked to adapt it.
A “pluggable” app is
   Easily Installed
            pip install coolapp
 You did declare your dependencies, right?
How do we make a
“pluggable” application?
Stop thinking like this




http://upload.wikimedia.org/wikipedia/commons/archive/a/aa/20090315161532!Ferrari_Enzo_Ferrari.JPG
and think like this




   http://www.flickr.com/photos/motagirl2/4301276868/
Applications can have
very different purposes




http://www.photoshoproadmap.com/imagenes/blog/lego-brushes/lego-bricks-high-resolution.jpg
Application Types
• Data. Manages specific data and access to it
• Utility. Provide aapplication a specific
  problem for any
                     way of handling



• Decorator.functionality of many applications
  aggregates
             Adds functionality to one or
Data Apps




http://www.geeky-gadgets.com/wp-content/uploads/2009/08/lego-usb-hub_2.jpg
Situation 1

       Lots of variations
Each implementation is different
          (e.g. blogs)
Abstract Models
            GLAMKit http://www.glamkit.org/


        EntryBase


   FeaturableEntryMixin


   StatusableEntryMixin


    TaggableEntryMixin


HTMLFormattableEntryMixin
Situation 2

A few, well-known of variations
 (e.g. Use django.contrib.sites?)
Optional Field Settings
Situation 3

 Optionally use another
        application
(e.g. Use django-tagging?)
Optional Integration
Optional Integration
Situation 3

    You want to reference
       different models
(e.g. Customizable author field)
Configurable
        Foreign Keys
Viewpoint http://github.com/washingtontimes
Situation 3

You want to provide hooks for
       other applications
(e.g. While processing in a view)
Emit Signals
Satchmo http://www.satchmoproject.com/
Utility Apps




http://www.1000steine.com/brickset/images/852759-1.jpg
Utility apps are
just code libraries
Projects with
template tags need one
Does it need to be in
                      ?

Yes, if you have:
• Templates
• Template Tags
• Management Commands
Decorator Apps




http://trendland.net/wp-content/uploads/2008/12/lego-ring.jpg
CoolApp
 New Method                New Field
Custom Manager             New Admin
Registering for Decoration
Simple Model Registry
Model-Data Registry
Lazy Registration
Situation 4

     You want to add a
      field to a model
(e.g. Link to another model)
Simple Model Registry
Situation 5

     You want to add a
    method to a model
(e.g. Link to another model)
Adding methods
Situation 6

      You want to customize
     a model’s ModelAdmin
(e.g. Change the widget of a field)
Lazy Registration of a
Custom ModelAdmin
Lazy Registration of a
Custom ModelAdmin
Lazy Registration of a
Custom ModelAdmin
Touch Points
Touch Points of an App
The parts of an application that
usually need tweaking
 • URLs
 • Templates
 • Configurable options
 • View responses
Situation 7

You want the URLs of your app to
      live under any prefix
    (e.g. /blogs/ vs. /weblogs/)
Name your URLs
Reference your
URLs by name
Situation 8

You want your templates
 to be easily overridable
“Namespace” Templates
  coolapp

        templates

              coolapp

                    base.html
“Namespace” Templates
                        All templates in
  coolapp                  a template
                        “name space”
        templates

              coolapp

                    base.html
“Namespace” Templates
  coolapp
                          All templates
        templates        extend a single
                            template
              coolapp

                    base.html
“Namespace” Templates
  coolapp

        templates       This template simply

              coolapp

                    base.html
Import your blocks
Allows you to override any of the templates

                              extra_head.html



                              content.html
      base.html
Situation 9

You want to configure your app
  without modifying its code
        (e.g. API keys)
Configurable Options
 Django Supertagging http://github.com/josesoa




Internal Name     Setting Name    Default Value
Configurable Options
Django Debug Toolbar http://github.com/robhudson
Define a Storage Option
Situation 10
   You want to alter the
   data your views use
(e.g. Extra context, different
          template)
Add keyword arguments
Django Registration http://bitbucket.org/ubernostrum
Class-based Views
http://github.com/bfirsh/django-class-based-views
http://github.com/pegasus/django-baseviews
http://code.djangoproject.com/ticket/6735
http://codysoyland.com/2010/feb/3/thread-safe-object-
oriented-views-django/
http://www.toddreed.name/content/django-view-class/
To be continued…
My Info

• coreyoordt@gmail.com
• @coordt
• github.com/coordt
• github.com/washingtontimes
• opensource.washingtontimes.com

Más contenido relacionado

La actualidad más candente

AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep DiveGabriel Walt
 
10 reasons to migrate from AEM 5 to 6.1
10 reasons to migrate from AEM 5 to 6.110 reasons to migrate from AEM 5 to 6.1
10 reasons to migrate from AEM 5 to 6.1Tricode (part of Dept)
 
5 x HTML5 worth using in APEX (5)
5 x HTML5 worth using in APEX (5)5 x HTML5 worth using in APEX (5)
5 x HTML5 worth using in APEX (5)Christian Rokitta
 
The Open-source Eclipse Plugin for Force.com Development, Summer ‘14
The Open-source Eclipse Plugin for Force.com Development, Summer ‘14The Open-source Eclipse Plugin for Force.com Development, Summer ‘14
The Open-source Eclipse Plugin for Force.com Development, Summer ‘14Salesforce Developers
 
Build single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEMBuild single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEMAdobeMarketingCloud
 
Introduction To Code Igniter
Introduction To Code IgniterIntroduction To Code Igniter
Introduction To Code IgniterAmzad Hossain
 
Publishing API documentation -- Presentation
Publishing API documentation -- PresentationPublishing API documentation -- Presentation
Publishing API documentation -- PresentationTom Johnson
 
Publishing API documentation -- Workshop
Publishing API documentation -- WorkshopPublishing API documentation -- Workshop
Publishing API documentation -- WorkshopTom Johnson
 
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentWordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentEvan Mullins
 
Sightly - AEM6 UI Development using JS and JAVA
Sightly - AEM6 UI Development using JS and JAVASightly - AEM6 UI Development using JS and JAVA
Sightly - AEM6 UI Development using JS and JAVAYash Mody
 
Instagram filters (8 24)
Instagram filters (8 24)Instagram filters (8 24)
Instagram filters (8 24)Ivy Rueb
 
Engage - Expanding XPages with Bootstrap Plugins for ultimate usability
Engage - Expanding XPages with Bootstrap Plugins for ultimate usabilityEngage - Expanding XPages with Bootstrap Plugins for ultimate usability
Engage - Expanding XPages with Bootstrap Plugins for ultimate usabilityJohnny Oldenburger
 
Instagram filters (8 24)
Instagram filters (8 24)Instagram filters (8 24)
Instagram filters (8 24)Ivy Rueb
 
ElggCamp Santiago - Dev Edition
ElggCamp Santiago - Dev EditionElggCamp Santiago - Dev Edition
ElggCamp Santiago - Dev EditionBrett Profitt
 
Eclipse Overview
Eclipse Overview Eclipse Overview
Eclipse Overview Lars Vogel
 
Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his Dutyreedmaniac
 
[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JS[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JSIvano Malavolta
 

La actualidad más candente (20)

AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep Dive
 
10 reasons to migrate from AEM 5 to 6.1
10 reasons to migrate from AEM 5 to 6.110 reasons to migrate from AEM 5 to 6.1
10 reasons to migrate from AEM 5 to 6.1
 
BDD, Behat & Drupal
BDD, Behat & DrupalBDD, Behat & Drupal
BDD, Behat & Drupal
 
5 x HTML5 worth using in APEX (5)
5 x HTML5 worth using in APEX (5)5 x HTML5 worth using in APEX (5)
5 x HTML5 worth using in APEX (5)
 
[2015/2016] JavaScript
[2015/2016] JavaScript[2015/2016] JavaScript
[2015/2016] JavaScript
 
The Open-source Eclipse Plugin for Force.com Development, Summer ‘14
The Open-source Eclipse Plugin for Force.com Development, Summer ‘14The Open-source Eclipse Plugin for Force.com Development, Summer ‘14
The Open-source Eclipse Plugin for Force.com Development, Summer ‘14
 
Build single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEMBuild single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEM
 
Introduction To Code Igniter
Introduction To Code IgniterIntroduction To Code Igniter
Introduction To Code Igniter
 
Publishing API documentation -- Presentation
Publishing API documentation -- PresentationPublishing API documentation -- Presentation
Publishing API documentation -- Presentation
 
Publishing API documentation -- Workshop
Publishing API documentation -- WorkshopPublishing API documentation -- Workshop
Publishing API documentation -- Workshop
 
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentWordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
 
Sightly - AEM6 UI Development using JS and JAVA
Sightly - AEM6 UI Development using JS and JAVASightly - AEM6 UI Development using JS and JAVA
Sightly - AEM6 UI Development using JS and JAVA
 
Instagram filters (8 24)
Instagram filters (8 24)Instagram filters (8 24)
Instagram filters (8 24)
 
Engage - Expanding XPages with Bootstrap Plugins for ultimate usability
Engage - Expanding XPages with Bootstrap Plugins for ultimate usabilityEngage - Expanding XPages with Bootstrap Plugins for ultimate usability
Engage - Expanding XPages with Bootstrap Plugins for ultimate usability
 
Instagram filters (8 24)
Instagram filters (8 24)Instagram filters (8 24)
Instagram filters (8 24)
 
Getting started with angular js
Getting started with angular jsGetting started with angular js
Getting started with angular js
 
ElggCamp Santiago - Dev Edition
ElggCamp Santiago - Dev EditionElggCamp Santiago - Dev Edition
ElggCamp Santiago - Dev Edition
 
Eclipse Overview
Eclipse Overview Eclipse Overview
Eclipse Overview
 
Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his Duty
 
[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JS[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JS
 

Similar a Pluggable patterns

Concepts and applications of Django.pptx
Concepts and applications of Django.pptxConcepts and applications of Django.pptx
Concepts and applications of Django.pptxsushmitjivtode4
 
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Mack Hardy
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineYared Ayalew
 
Angular - Chapter 1 - Introduction
 Angular - Chapter 1 - Introduction Angular - Chapter 1 - Introduction
Angular - Chapter 1 - IntroductionWebStackAcademy
 
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slidesKeep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slidesJer Clarke
 
Handlebars and Require.js
Handlebars and Require.jsHandlebars and Require.js
Handlebars and Require.jsIvano Malavolta
 
Web Development in Django
Web Development in DjangoWeb Development in Django
Web Development in DjangoLakshman Prasad
 
Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Tony Frame
 
Seattle bestpractices2010
Seattle bestpractices2010Seattle bestpractices2010
Seattle bestpractices2010Olaseni Odebiyi
 
بررسی چارچوب جنگو
بررسی چارچوب جنگوبررسی چارچوب جنگو
بررسی چارچوب جنگوrailsbootcamp
 
Introduction to Google App Engine with Python
Introduction to Google App Engine with PythonIntroduction to Google App Engine with Python
Introduction to Google App Engine with PythonBrian Lyttle
 
Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Angela Byron
 
Implementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing CompanyImplementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing CompanyMarcos Labad
 
Dev days Szeged 2014: Plugin system in drupal 8
Dev days Szeged 2014: Plugin system in drupal 8Dev days Szeged 2014: Plugin system in drupal 8
Dev days Szeged 2014: Plugin system in drupal 8Bram Goffings
 
Mongodb at-gilt-groupe-seattle-2012-09-14-final
Mongodb at-gilt-groupe-seattle-2012-09-14-finalMongodb at-gilt-groupe-seattle-2012-09-14-final
Mongodb at-gilt-groupe-seattle-2012-09-14-finalMongoDB
 

Similar a Pluggable patterns (20)

Reusable Apps
Reusable AppsReusable Apps
Reusable Apps
 
Concepts and applications of Django.pptx
Concepts and applications of Django.pptxConcepts and applications of Django.pptx
Concepts and applications of Django.pptx
 
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
 
Django in the Real World
Django in the Real WorldDjango in the Real World
Django in the Real World
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App Engine
 
Angular - Chapter 1 - Introduction
 Angular - Chapter 1 - Introduction Angular - Chapter 1 - Introduction
Angular - Chapter 1 - Introduction
 
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slidesKeep Your Code Organized! WordCamp Montreal 2013 Presentation slides
Keep Your Code Organized! WordCamp Montreal 2013 Presentation slides
 
Handlebars and Require.js
Handlebars and Require.jsHandlebars and Require.js
Handlebars and Require.js
 
Web Development in Django
Web Development in DjangoWeb Development in Django
Web Development in Django
 
Apache Cordova
Apache CordovaApache Cordova
Apache Cordova
 
Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01Googleappengineintro 110410190620-phpapp01
Googleappengineintro 110410190620-phpapp01
 
Seattle bestpractices2010
Seattle bestpractices2010Seattle bestpractices2010
Seattle bestpractices2010
 
بررسی چارچوب جنگو
بررسی چارچوب جنگوبررسی چارچوب جنگو
بررسی چارچوب جنگو
 
Introduction to Google App Engine with Python
Introduction to Google App Engine with PythonIntroduction to Google App Engine with Python
Introduction to Google App Engine with Python
 
Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8
 
Architecting iOS Project
Architecting iOS ProjectArchitecting iOS Project
Architecting iOS Project
 
Implementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing CompanyImplementing a Symfony Based CMS in a Publishing Company
Implementing a Symfony Based CMS in a Publishing Company
 
Dev days Szeged 2014: Plugin system in drupal 8
Dev days Szeged 2014: Plugin system in drupal 8Dev days Szeged 2014: Plugin system in drupal 8
Dev days Szeged 2014: Plugin system in drupal 8
 
Mongodb at-gilt-groupe-seattle-2012-09-14-final
Mongodb at-gilt-groupe-seattle-2012-09-14-finalMongodb at-gilt-groupe-seattle-2012-09-14-final
Mongodb at-gilt-groupe-seattle-2012-09-14-final
 
Handlebars & Require JS
Handlebars  & Require JSHandlebars  & Require JS
Handlebars & Require JS
 

Pluggable patterns