SlideShare une entreprise Scribd logo
1  sur  61
Télécharger pour lire hors ligne
Pluggable Patterns
                           For Reusable Django Applications




Friday, March 11, 2011
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
Friday, March 11, 2011
An application should
                            be “pluggable”


Friday, March 11, 2011
A “pluggable” app is
                               Focused
                         Write programs that do one thing and do it well.
                            — Doug McIlroy (inventor of UNIX pipes)

Friday, March 11, 2011
A “pluggable” app is
                            Self-Contained
                               Batteries are included
                             Dependencies are declared

Friday, March 11, 2011
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.

Friday, March 11, 2011
A “pluggable” app is
                            Easily Installed
                                     pip install coolapp
                          You did declare your dependencies, right?

Friday, March 11, 2011
How do we make a
                 “pluggable” application?


Friday, March 11, 2011
Stop thinking like this




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




Friday, March 11, 2011
Applications can have
                     very different purposes




                                  http://www.flickr.com/photos/tiemposdelruido/4051083769/
Friday, March 11, 2011
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



Friday, March 11, 2011
Situation 1

                   You want to configure your app
                     without modifying its code
                           (e.g. API keys)



Friday, March 11, 2011
Configurable Options
                         Django Supertagging http://github.com/josesoa




                  Internal Name           Setting Name    Default Value




Friday, March 11, 2011
Configurable Options
               Django Debug Toolbar http://github.com/robhudson




Friday, March 11, 2011
Data Apps




                         http://www.flickr.com/photos/29276244@N03/3200630853/
Friday, March 11, 2011
Situation 2

                       Lots of variations
                Each implementation is different
                          (e.g. blogs)



Friday, March 11, 2011
Abstract Models
                                  GLAMKit http://www.glamkit.org/


                              EntryBase


                         FeaturableEntryMixin


                         StatusableEntryMixin


                         TaggableEntryMixin


                    HTMLFormattableEntryMixin




Friday, March 11, 2011
Situation 3

                  A few, well-known of variations
                   (e.g. Use django.contrib.sites?)




Friday, March 11, 2011
Optional Field Settings




Friday, March 11, 2011
Situation 4

                          Optionally use another
                                 application
                         (e.g. Use django-tagging?)



Friday, March 11, 2011
Optional Integration




Friday, March 11, 2011
Situation 5

                             You want to reference
                                different models
                         (e.g. Customizable author field)



Friday, March 11, 2011
Runtime Configurable
                             Foreign Keys
                         Viewpoint http://github.com/washingtontimes




Friday, March 11, 2011
Runtime Configurable
                             Foreign Keys
                         Viewpoint http://github.com/washingtontimes




Friday, March 11, 2011
Utility Apps




                         http://www.flickr.com/photos/s8/3638531205/
Friday, March 11, 2011
Required for
                     template tags or
                  management commands
Friday, March 11, 2011
Decorator Apps




                          http://www.flickr.com/photos/yum9me/2109549869/
Friday, March 11, 2011
New Method   New Field




       Custom Manager           New Admin




Friday, March 11, 2011
Situation 6

                         You want to add a
                          field to a model




Friday, March 11, 2011
Lazy Field Insertion
             Django Categories http://github.com/washingtontimes




Friday, March 11, 2011
Lazy Field Insertion
             Django Categories http://github.com/washingtontimes




Friday, March 11, 2011
Lazy Field Insertion
             Django Categories http://github.com/washingtontimes




Friday, March 11, 2011
Situation 7

                              You want to add a
                         custom manager to a model




Friday, March 11, 2011
Lazy Manager Insertion
                         Django MPTT http://github.com/django-mptt




Friday, March 11, 2011
Adding a manager
                         Django MPTT http://github.com/django-mptt
                   from django.db.models import get_model
                   import django.conf import settings
                   from coolapp.managers import CustomManager

                   MODELS = getattr(settings, 'COOLAPP_MODELS', {})

                   for model_name, mgr_name in MODELS.items():
                       if not isinstance(model_name, basestring):
                           continue

                          model = get_model(*model_name.split('.'))

                          if not getattr(model, mgr_name, False):
                              manager = CustomManager()
                              manager.contribute_to_class(model, mgr_name)



Friday, March 11, 2011
Situation 8

                        You want to customize
                       a model’s ModelAdmin
                  (e.g. Change the widget of a field)



Friday, March 11, 2011
Lazy Registration of a
                         Custom ModelAdmin
                         Django TinyMCE http://github.com/justquick




                                    project’s settings.py
Friday, March 11, 2011
Lazy Registration of a
                         Custom ModelAdmin
                         Django TinyMCE http://github.com/justquick




                                Django-TinyMCE’s models.py
Friday, March 11, 2011
Lazy Registration of a
                         Custom ModelAdmin
                         Django TinyMCE http://github.com/justquick




                                 Django-TinyMCE’s admin.py
Friday, March 11, 2011
Lazy Registration of a
                         Custom ModelAdmin
                         Django TinyMCE http://github.com/justquick




                            bottom of Django-TinyMCE’s admin.py
Friday, March 11, 2011
Touch Points




Friday, March 11, 2011
Touch Points of an App

                         The parts of an application that
                         usually need tweaking
                          • URLs
                          • Templates
                          • View responses

Friday, March 11, 2011
Situation 9

              You want the URLs of your app to
                    live under any prefix
                  (e.g. /blogs/ vs. /weblogs/)



Friday, March 11, 2011
Name your URLs




Friday, March 11, 2011
Name your URLs



                  url Function     name




Friday, March 11, 2011
Reference your
                         URLs by name




Friday, March 11, 2011
Situation 10

                         You want your templates
                          to be easily overridable




Friday, March 11, 2011
“Namespace” Templates
                                               All templates in
                         coolapp                  a template
                                               “name space”
                               templates

                                     coolapp

                                           base.html


Friday, March 11, 2011
“Namespace” Templates
                         coolapp

                               templates

                                     coolapp

       Referenced as                       base.html
    “coolapp/base.html”

Friday, March 11, 2011
Extend one template
                         site_base.html   base.html




                         summary.html     index.html   detail.html
Friday, March 11, 2011
Extend one template
                         site_base.html   base.html




                                          base.html




                         summary.html     index.html   detail.html
Friday, March 11, 2011
Extend one template
                         site_base.html   base.html




                                          base.html




                         summary.html     index.html   detail.html
Friday, March 11, 2011
Extend one template




                             coolapp/base.html
Friday, March 11, 2011
Extend one template




                             coolapp/base.html
Friday, March 11, 2011
Import your blocks
       Allows you to override any of the templates

                                       extra_head.html




                 coolapp/detail.html
Friday, March 11, 2011
Situation 11

                         You want flexibility storing
                              uploaded files




Friday, March 11, 2011
Define a Storage Option




Friday, March 11, 2011
Situation 12
                            You want to alter the
                            data your views use
                         (e.g. Extra context, different
                                   template)



Friday, March 11, 2011
100% more class-
                           based views!

                          django-cbv for
                            backwards
                          compatibility!
Friday, March 11, 2011
My Info

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

Friday, March 11, 2011

Contenu connexe

Tendances

Azure Infrastructure as Code and Hashicorp Terraform
Azure Infrastructure as Code and Hashicorp TerraformAzure Infrastructure as Code and Hashicorp Terraform
Azure Infrastructure as Code and Hashicorp TerraformAlex Mags
 
Introduction to Lean Analytics webinar (O'Reilly)
Introduction to Lean Analytics webinar (O'Reilly)Introduction to Lean Analytics webinar (O'Reilly)
Introduction to Lean Analytics webinar (O'Reilly)Lean Analytics
 
Jenkins - From Continuous Integration to Continuous Delivery
Jenkins - From Continuous Integration to Continuous DeliveryJenkins - From Continuous Integration to Continuous Delivery
Jenkins - From Continuous Integration to Continuous DeliveryVirendra Bhalothia
 
How Startups Can Build a Recruiting Machine
How Startups Can Build a Recruiting MachineHow Startups Can Build a Recruiting Machine
How Startups Can Build a Recruiting MachineDavid Skok
 
Building better Node.js applications on MariaDB
Building better Node.js applications on MariaDBBuilding better Node.js applications on MariaDB
Building better Node.js applications on MariaDBMariaDB plc
 
Time to Wow! and Buyer-centric Funnel Design
Time to Wow! and Buyer-centric Funnel DesignTime to Wow! and Buyer-centric Funnel Design
Time to Wow! and Buyer-centric Funnel DesignDavid Skok
 
Get inside your Buyers Head - Improve Funnel Conversion Rates
Get inside your Buyers Head - Improve Funnel Conversion RatesGet inside your Buyers Head - Improve Funnel Conversion Rates
Get inside your Buyers Head - Improve Funnel Conversion RatesDavid Skok
 
JSF2.2で簡単webアプリケーション開発
JSF2.2で簡単webアプリケーション開発JSF2.2で簡単webアプリケーション開発
JSF2.2で簡単webアプリケーション開発Masuji Katoda
 
Buyer Centric Funnel Design
Buyer Centric Funnel DesignBuyer Centric Funnel Design
Buyer Centric Funnel DesignDavid Skok
 
Zero to 100 - Part 4: Building a Sales Team - Stephanie Schatz
Zero to 100 - Part 4: Building a Sales Team - Stephanie SchatzZero to 100 - Part 4: Building a Sales Team - Stephanie Schatz
Zero to 100 - Part 4: Building a Sales Team - Stephanie SchatzDavid Skok
 
Kellogg SaaStock C-Suite and Ground Truth^LLLLJ r1.5.pdf
Kellogg SaaStock C-Suite and Ground Truth^LLLLJ r1.5.pdfKellogg SaaStock C-Suite and Ground Truth^LLLLJ r1.5.pdf
Kellogg SaaStock C-Suite and Ground Truth^LLLLJ r1.5.pdfDave Kellogg
 
A KPI framework for startups
A KPI framework for startupsA KPI framework for startups
A KPI framework for startupsyalisassoon
 
Zero to 100 - Part 5: SaaS Business Model & Metrics
Zero to 100 - Part 5: SaaS Business Model & MetricsZero to 100 - Part 5: SaaS Business Model & Metrics
Zero to 100 - Part 5: SaaS Business Model & MetricsDavid Skok
 
Continuous delivery with jenkins pipelines (@devfest Vienna)
Continuous delivery with jenkins pipelines (@devfest Vienna)Continuous delivery with jenkins pipelines (@devfest Vienna)
Continuous delivery with jenkins pipelines (@devfest Vienna)Roman Pickl
 
Amazon DynamoDB Under the Hood: How We Built a Hyper-Scale Database (DAT321) ...
Amazon DynamoDB Under the Hood: How We Built a Hyper-Scale Database (DAT321) ...Amazon DynamoDB Under the Hood: How We Built a Hyper-Scale Database (DAT321) ...
Amazon DynamoDB Under the Hood: How We Built a Hyper-Scale Database (DAT321) ...Amazon Web Services
 
29 Growth Hacking Quick Wins
29 Growth Hacking Quick Wins29 Growth Hacking Quick Wins
29 Growth Hacking Quick WinsMattan Griffel
 
내가써본 nGrinder-SpringCamp 2015
내가써본 nGrinder-SpringCamp 2015내가써본 nGrinder-SpringCamp 2015
내가써본 nGrinder-SpringCamp 2015Lim SungHyun
 

Tendances (20)

Azure Infrastructure as Code and Hashicorp Terraform
Azure Infrastructure as Code and Hashicorp TerraformAzure Infrastructure as Code and Hashicorp Terraform
Azure Infrastructure as Code and Hashicorp Terraform
 
Introduction to Lean Analytics webinar (O'Reilly)
Introduction to Lean Analytics webinar (O'Reilly)Introduction to Lean Analytics webinar (O'Reilly)
Introduction to Lean Analytics webinar (O'Reilly)
 
Jenkins - From Continuous Integration to Continuous Delivery
Jenkins - From Continuous Integration to Continuous DeliveryJenkins - From Continuous Integration to Continuous Delivery
Jenkins - From Continuous Integration to Continuous Delivery
 
How Startups Can Build a Recruiting Machine
How Startups Can Build a Recruiting MachineHow Startups Can Build a Recruiting Machine
How Startups Can Build a Recruiting Machine
 
DevOps on AWS
DevOps on AWSDevOps on AWS
DevOps on AWS
 
Building better Node.js applications on MariaDB
Building better Node.js applications on MariaDBBuilding better Node.js applications on MariaDB
Building better Node.js applications on MariaDB
 
Time to Wow! and Buyer-centric Funnel Design
Time to Wow! and Buyer-centric Funnel DesignTime to Wow! and Buyer-centric Funnel Design
Time to Wow! and Buyer-centric Funnel Design
 
Get inside your Buyers Head - Improve Funnel Conversion Rates
Get inside your Buyers Head - Improve Funnel Conversion RatesGet inside your Buyers Head - Improve Funnel Conversion Rates
Get inside your Buyers Head - Improve Funnel Conversion Rates
 
JSF2.2で簡単webアプリケーション開発
JSF2.2で簡単webアプリケーション開発JSF2.2で簡単webアプリケーション開発
JSF2.2で簡単webアプリケーション開発
 
Buyer Centric Funnel Design
Buyer Centric Funnel DesignBuyer Centric Funnel Design
Buyer Centric Funnel Design
 
Zero to 100 - Part 4: Building a Sales Team - Stephanie Schatz
Zero to 100 - Part 4: Building a Sales Team - Stephanie SchatzZero to 100 - Part 4: Building a Sales Team - Stephanie Schatz
Zero to 100 - Part 4: Building a Sales Team - Stephanie Schatz
 
Kellogg SaaStock C-Suite and Ground Truth^LLLLJ r1.5.pdf
Kellogg SaaStock C-Suite and Ground Truth^LLLLJ r1.5.pdfKellogg SaaStock C-Suite and Ground Truth^LLLLJ r1.5.pdf
Kellogg SaaStock C-Suite and Ground Truth^LLLLJ r1.5.pdf
 
A KPI framework for startups
A KPI framework for startupsA KPI framework for startups
A KPI framework for startups
 
Introduction to AWS Glue
Introduction to AWS Glue Introduction to AWS Glue
Introduction to AWS Glue
 
Zero to 100 - Part 5: SaaS Business Model & Metrics
Zero to 100 - Part 5: SaaS Business Model & MetricsZero to 100 - Part 5: SaaS Business Model & Metrics
Zero to 100 - Part 5: SaaS Business Model & Metrics
 
Continuous delivery with jenkins pipelines (@devfest Vienna)
Continuous delivery with jenkins pipelines (@devfest Vienna)Continuous delivery with jenkins pipelines (@devfest Vienna)
Continuous delivery with jenkins pipelines (@devfest Vienna)
 
Amazon DynamoDB Under the Hood: How We Built a Hyper-Scale Database (DAT321) ...
Amazon DynamoDB Under the Hood: How We Built a Hyper-Scale Database (DAT321) ...Amazon DynamoDB Under the Hood: How We Built a Hyper-Scale Database (DAT321) ...
Amazon DynamoDB Under the Hood: How We Built a Hyper-Scale Database (DAT321) ...
 
Jenkins.pdf
Jenkins.pdfJenkins.pdf
Jenkins.pdf
 
29 Growth Hacking Quick Wins
29 Growth Hacking Quick Wins29 Growth Hacking Quick Wins
29 Growth Hacking Quick Wins
 
내가써본 nGrinder-SpringCamp 2015
내가써본 nGrinder-SpringCamp 2015내가써본 nGrinder-SpringCamp 2015
내가써본 nGrinder-SpringCamp 2015
 

Similaire à Pluggable Django Application Patterns PyCon 2011

Using Drupal for School or District Website
Using Drupal for School or District WebsiteUsing Drupal for School or District Website
Using Drupal for School or District Websitedserrato
 
A Look at the Future of HTML5
A Look at the Future of HTML5A Look at the Future of HTML5
A Look at the Future of HTML5Tim Wright
 
3D in the Browser via WebGL: It's Go Time
3D in the Browser via WebGL: It's Go Time 3D in the Browser via WebGL: It's Go Time
3D in the Browser via WebGL: It's Go Time Pascal Rettig
 
Regional News in Times of iPad, Twitter & Co. (Cassini Convention, Nov. 2010)
Regional News in Times of iPad, Twitter & Co. (Cassini Convention, Nov. 2010)Regional News in Times of iPad, Twitter & Co. (Cassini Convention, Nov. 2010)
Regional News in Times of iPad, Twitter & Co. (Cassini Convention, Nov. 2010)gkamp
 
Meet magento 2011-templating
Meet magento 2011-templatingMeet magento 2011-templating
Meet magento 2011-templatingHans Kuijpers
 
Flowdock's full-text search with MongoDB
Flowdock's full-text search with MongoDBFlowdock's full-text search with MongoDB
Flowdock's full-text search with MongoDBFlowdock
 
Chris Rault - Content construction with ZOO
Chris Rault - Content construction with ZOOChris Rault - Content construction with ZOO
Chris Rault - Content construction with ZOOJoomla Day South Africa
 
iPhone App from concept to product
iPhone App from concept to productiPhone App from concept to product
iPhone App from concept to productjoeysim
 
Using+javascript+to+build+native+i os+applications
Using+javascript+to+build+native+i os+applicationsUsing+javascript+to+build+native+i os+applications
Using+javascript+to+build+native+i os+applicationsMuhammad Ikram Ul Haq
 
The Fast, The Slow and the Lazy
The Fast, The Slow and the LazyThe Fast, The Slow and the Lazy
The Fast, The Slow and the LazyMaurício Linhares
 
2011 June - Singapore GTUG presentation. App Engine program update + intro to Go
2011 June - Singapore GTUG presentation. App Engine program update + intro to Go2011 June - Singapore GTUG presentation. App Engine program update + intro to Go
2011 June - Singapore GTUG presentation. App Engine program update + intro to Goikailan
 
Simon Cross - Facebook Mobile, First - Geomob Feb 2011
Simon Cross -  Facebook Mobile, First - Geomob Feb 2011Simon Cross -  Facebook Mobile, First - Geomob Feb 2011
Simon Cross - Facebook Mobile, First - Geomob Feb 2011GeomobLDN
 
Frozen Rails Slides
Frozen Rails SlidesFrozen Rails Slides
Frozen Rails Slidescarllerche
 
Gaelyk - Guillaume Laforge - GR8Conf Europe 2011
Gaelyk - Guillaume Laforge - GR8Conf Europe 2011Gaelyk - Guillaume Laforge - GR8Conf Europe 2011
Gaelyk - Guillaume Laforge - GR8Conf Europe 2011Guillaume Laforge
 
Mobile apps using drupal as base system SumitK DrupalCon Chicago
Mobile apps using drupal as base system   SumitK DrupalCon ChicagoMobile apps using drupal as base system   SumitK DrupalCon Chicago
Mobile apps using drupal as base system SumitK DrupalCon ChicagoSumit Kataria
 
Writing jQuery that doesn't suck - London jQuery
Writing jQuery that doesn't suck - London jQueryWriting jQuery that doesn't suck - London jQuery
Writing jQuery that doesn't suck - London jQueryRoss Bruniges
 
MarkLogic Developer Community Resources, September 2013
MarkLogic Developer Community Resources, September 2013MarkLogic Developer Community Resources, September 2013
MarkLogic Developer Community Resources, September 2013Eric Bloch
 

Similaire à Pluggable Django Application Patterns PyCon 2011 (20)

Using Drupal for School or District Website
Using Drupal for School or District WebsiteUsing Drupal for School or District Website
Using Drupal for School or District Website
 
A Look at the Future of HTML5
A Look at the Future of HTML5A Look at the Future of HTML5
A Look at the Future of HTML5
 
Groke
GrokeGroke
Groke
 
3D in the Browser via WebGL: It's Go Time
3D in the Browser via WebGL: It's Go Time 3D in the Browser via WebGL: It's Go Time
3D in the Browser via WebGL: It's Go Time
 
Regional News in Times of iPad, Twitter & Co. (Cassini Convention, Nov. 2010)
Regional News in Times of iPad, Twitter & Co. (Cassini Convention, Nov. 2010)Regional News in Times of iPad, Twitter & Co. (Cassini Convention, Nov. 2010)
Regional News in Times of iPad, Twitter & Co. (Cassini Convention, Nov. 2010)
 
Meet magento 2011-templating
Meet magento 2011-templatingMeet magento 2011-templating
Meet magento 2011-templating
 
Flowdock's full-text search with MongoDB
Flowdock's full-text search with MongoDBFlowdock's full-text search with MongoDB
Flowdock's full-text search with MongoDB
 
Chris Rault - Content construction with ZOO
Chris Rault - Content construction with ZOOChris Rault - Content construction with ZOO
Chris Rault - Content construction with ZOO
 
iPhone App from concept to product
iPhone App from concept to productiPhone App from concept to product
iPhone App from concept to product
 
Using+javascript+to+build+native+i os+applications
Using+javascript+to+build+native+i os+applicationsUsing+javascript+to+build+native+i os+applications
Using+javascript+to+build+native+i os+applications
 
The Fast, The Slow and the Lazy
The Fast, The Slow and the LazyThe Fast, The Slow and the Lazy
The Fast, The Slow and the Lazy
 
2011 June - Singapore GTUG presentation. App Engine program update + intro to Go
2011 June - Singapore GTUG presentation. App Engine program update + intro to Go2011 June - Singapore GTUG presentation. App Engine program update + intro to Go
2011 June - Singapore GTUG presentation. App Engine program update + intro to Go
 
Simon Cross - Facebook Mobile, First - Geomob Feb 2011
Simon Cross -  Facebook Mobile, First - Geomob Feb 2011Simon Cross -  Facebook Mobile, First - Geomob Feb 2011
Simon Cross - Facebook Mobile, First - Geomob Feb 2011
 
Frozen Rails Slides
Frozen Rails SlidesFrozen Rails Slides
Frozen Rails Slides
 
Gaelyk - Guillaume Laforge - GR8Conf Europe 2011
Gaelyk - Guillaume Laforge - GR8Conf Europe 2011Gaelyk - Guillaume Laforge - GR8Conf Europe 2011
Gaelyk - Guillaume Laforge - GR8Conf Europe 2011
 
Mobile apps using drupal as base system SumitK DrupalCon Chicago
Mobile apps using drupal as base system   SumitK DrupalCon ChicagoMobile apps using drupal as base system   SumitK DrupalCon Chicago
Mobile apps using drupal as base system SumitK DrupalCon Chicago
 
Writing jQuery that doesn't suck - London jQuery
Writing jQuery that doesn't suck - London jQueryWriting jQuery that doesn't suck - London jQuery
Writing jQuery that doesn't suck - London jQuery
 
Anarchist guide to titanium ui
Anarchist guide to titanium uiAnarchist guide to titanium ui
Anarchist guide to titanium ui
 
The Third WordPress
The Third WordPressThe Third WordPress
The Third WordPress
 
MarkLogic Developer Community Resources, September 2013
MarkLogic Developer Community Resources, September 2013MarkLogic Developer Community Resources, September 2013
MarkLogic Developer Community Resources, September 2013
 

Dernier

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
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
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 

Dernier (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
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...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

Pluggable Django Application Patterns PyCon 2011

  • 1. Pluggable Patterns For Reusable Django Applications Friday, March 11, 2011
  • 2. 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 Friday, March 11, 2011
  • 3. An application should be “pluggable” Friday, March 11, 2011
  • 4. A “pluggable” app is Focused Write programs that do one thing and do it well. — Doug McIlroy (inventor of UNIX pipes) Friday, March 11, 2011
  • 5. A “pluggable” app is Self-Contained Batteries are included Dependencies are declared Friday, March 11, 2011
  • 6. 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. Friday, March 11, 2011
  • 7. A “pluggable” app is Easily Installed pip install coolapp You did declare your dependencies, right? Friday, March 11, 2011
  • 8. How do we make a “pluggable” application? Friday, March 11, 2011
  • 9. Stop thinking like this http://upload.wikimedia.org/wikipedia/commons/archive/a/aa/20090315161532!Ferrari_Enzo_Ferrari.JPG Friday, March 11, 2011
  • 10. and think like this Friday, March 11, 2011
  • 11. Applications can have very different purposes http://www.flickr.com/photos/tiemposdelruido/4051083769/ Friday, March 11, 2011
  • 12. 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 Friday, March 11, 2011
  • 13. Situation 1 You want to configure your app without modifying its code (e.g. API keys) Friday, March 11, 2011
  • 14. Configurable Options Django Supertagging http://github.com/josesoa Internal Name Setting Name Default Value Friday, March 11, 2011
  • 15. Configurable Options Django Debug Toolbar http://github.com/robhudson Friday, March 11, 2011
  • 16. Data Apps http://www.flickr.com/photos/29276244@N03/3200630853/ Friday, March 11, 2011
  • 17. Situation 2 Lots of variations Each implementation is different (e.g. blogs) Friday, March 11, 2011
  • 18. Abstract Models GLAMKit http://www.glamkit.org/ EntryBase FeaturableEntryMixin StatusableEntryMixin TaggableEntryMixin HTMLFormattableEntryMixin Friday, March 11, 2011
  • 19. Situation 3 A few, well-known of variations (e.g. Use django.contrib.sites?) Friday, March 11, 2011
  • 21. Situation 4 Optionally use another application (e.g. Use django-tagging?) Friday, March 11, 2011
  • 23. Situation 5 You want to reference different models (e.g. Customizable author field) Friday, March 11, 2011
  • 24. Runtime Configurable Foreign Keys Viewpoint http://github.com/washingtontimes Friday, March 11, 2011
  • 25. Runtime Configurable Foreign Keys Viewpoint http://github.com/washingtontimes Friday, March 11, 2011
  • 26. Utility Apps http://www.flickr.com/photos/s8/3638531205/ Friday, March 11, 2011
  • 27. Required for template tags or management commands Friday, March 11, 2011
  • 28. Decorator Apps http://www.flickr.com/photos/yum9me/2109549869/ Friday, March 11, 2011
  • 29. New Method New Field Custom Manager New Admin Friday, March 11, 2011
  • 30. Situation 6 You want to add a field to a model Friday, March 11, 2011
  • 31. Lazy Field Insertion Django Categories http://github.com/washingtontimes Friday, March 11, 2011
  • 32. Lazy Field Insertion Django Categories http://github.com/washingtontimes Friday, March 11, 2011
  • 33. Lazy Field Insertion Django Categories http://github.com/washingtontimes Friday, March 11, 2011
  • 34. Situation 7 You want to add a custom manager to a model Friday, March 11, 2011
  • 35. Lazy Manager Insertion Django MPTT http://github.com/django-mptt Friday, March 11, 2011
  • 36. Adding a manager Django MPTT http://github.com/django-mptt from django.db.models import get_model import django.conf import settings from coolapp.managers import CustomManager MODELS = getattr(settings, 'COOLAPP_MODELS', {}) for model_name, mgr_name in MODELS.items(): if not isinstance(model_name, basestring): continue model = get_model(*model_name.split('.')) if not getattr(model, mgr_name, False): manager = CustomManager() manager.contribute_to_class(model, mgr_name) Friday, March 11, 2011
  • 37. Situation 8 You want to customize a model’s ModelAdmin (e.g. Change the widget of a field) Friday, March 11, 2011
  • 38. Lazy Registration of a Custom ModelAdmin Django TinyMCE http://github.com/justquick project’s settings.py Friday, March 11, 2011
  • 39. Lazy Registration of a Custom ModelAdmin Django TinyMCE http://github.com/justquick Django-TinyMCE’s models.py Friday, March 11, 2011
  • 40. Lazy Registration of a Custom ModelAdmin Django TinyMCE http://github.com/justquick Django-TinyMCE’s admin.py Friday, March 11, 2011
  • 41. Lazy Registration of a Custom ModelAdmin Django TinyMCE http://github.com/justquick bottom of Django-TinyMCE’s admin.py Friday, March 11, 2011
  • 43. Touch Points of an App The parts of an application that usually need tweaking • URLs • Templates • View responses Friday, March 11, 2011
  • 44. Situation 9 You want the URLs of your app to live under any prefix (e.g. /blogs/ vs. /weblogs/) Friday, March 11, 2011
  • 45. Name your URLs Friday, March 11, 2011
  • 46. Name your URLs url Function name Friday, March 11, 2011
  • 47. Reference your URLs by name Friday, March 11, 2011
  • 48. Situation 10 You want your templates to be easily overridable Friday, March 11, 2011
  • 49. “Namespace” Templates All templates in coolapp a template “name space” templates coolapp base.html Friday, March 11, 2011
  • 50. “Namespace” Templates coolapp templates coolapp Referenced as base.html “coolapp/base.html” Friday, March 11, 2011
  • 51. Extend one template site_base.html base.html summary.html index.html detail.html Friday, March 11, 2011
  • 52. Extend one template site_base.html base.html base.html summary.html index.html detail.html Friday, March 11, 2011
  • 53. Extend one template site_base.html base.html base.html summary.html index.html detail.html Friday, March 11, 2011
  • 54. Extend one template coolapp/base.html Friday, March 11, 2011
  • 55. Extend one template coolapp/base.html Friday, March 11, 2011
  • 56. Import your blocks Allows you to override any of the templates extra_head.html coolapp/detail.html Friday, March 11, 2011
  • 57. Situation 11 You want flexibility storing uploaded files Friday, March 11, 2011
  • 58. Define a Storage Option Friday, March 11, 2011
  • 59. Situation 12 You want to alter the data your views use (e.g. Extra context, different template) Friday, March 11, 2011
  • 60. 100% more class- based views! django-cbv for backwards compatibility! Friday, March 11, 2011
  • 61. My Info • coreyoordt@gmail.com • @coordt • github.com/coordt • github.com/washingtontimes • opensource.washingtontimes.com Friday, March 11, 2011