SlideShare a Scribd company logo
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

More Related Content

What's hot

Curso de Performance and Tuning - Linux
Curso de Performance and Tuning - LinuxCurso de Performance and Tuning - Linux
Curso de Performance and Tuning - Linux
Dell Technologies
 
Windows Server 2016: Servidor de DHCP
Windows Server 2016: Servidor de DHCPWindows Server 2016: Servidor de DHCP
Windows Server 2016: Servidor de DHCP
Juan Ignacio Oller Aznar
 
ITIL v3 Problem Management
ITIL v3 Problem ManagementITIL v3 Problem Management
ITIL v3 Problem Management
Josep Bardallo
 
Proxysql sharding
Proxysql shardingProxysql sharding
Proxysql sharding
Marco Tusa
 
Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!
Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!
Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!
Serdar Basegmez
 
Mantis Profile & WMS Overview
Mantis Profile & WMS OverviewMantis Profile & WMS Overview
Mantis Profile & WMS OverviewMantis Romania
 
MySQL GTID Concepts, Implementation and troubleshooting
MySQL GTID Concepts, Implementation and troubleshooting MySQL GTID Concepts, Implementation and troubleshooting
MySQL GTID Concepts, Implementation and troubleshooting
Mydbops
 
Fundamentos de BI
Fundamentos de BIFundamentos de BI
Fundamentos de BI
JOSE AHIAS LOPEZ PORTILLO
 
Support de cours angular
Support de cours angularSupport de cours angular
Support de cours angular
ENSET, Université Hassan II Casablanca
 
OpenNTF Domino API (ODA): Super-Charging Domino Development
OpenNTF Domino API (ODA): Super-Charging Domino DevelopmentOpenNTF Domino API (ODA): Super-Charging Domino Development
OpenNTF Domino API (ODA): Super-Charging Domino Development
Paul Withers
 
Best Practices for Configuring Your OSSIM Installation
Best Practices for Configuring Your OSSIM InstallationBest Practices for Configuring Your OSSIM Installation
Best Practices for Configuring Your OSSIM Installation
AlienVault
 
Odoo icon smart buttons
Odoo   icon smart buttonsOdoo   icon smart buttons
Odoo icon smart buttons
Taieb Kristou
 
Conférence: Catalyseurs de l'Intelligence Artificielle et Écosystème des Fram...
Conférence: Catalyseurs de l'Intelligence Artificielle et Écosystème des Fram...Conférence: Catalyseurs de l'Intelligence Artificielle et Écosystème des Fram...
Conférence: Catalyseurs de l'Intelligence Artificielle et Écosystème des Fram...
ENSET, Université Hassan II Casablanca
 
ITIL Introduction
ITIL IntroductionITIL Introduction
ITIL Introduction
Linpei Zhang
 
MySQL InnoDB Cluster and NDB Cluster
MySQL InnoDB Cluster and NDB ClusterMySQL InnoDB Cluster and NDB Cluster
MySQL InnoDB Cluster and NDB Cluster
Mario Beck
 
ServiceNow - Introduction.pptx
ServiceNow - Introduction.pptxServiceNow - Introduction.pptx
ServiceNow - Introduction.pptx
UjjwalPandit7
 
M|18 How MariaDB Server Scales with Spider
M|18 How MariaDB Server Scales with SpiderM|18 How MariaDB Server Scales with Spider
M|18 How MariaDB Server Scales with Spider
MariaDB plc
 
High Availability and Disaster Recovery in PostgreSQL - EQUNIX
High Availability and Disaster Recovery in PostgreSQL - EQUNIXHigh Availability and Disaster Recovery in PostgreSQL - EQUNIX
High Availability and Disaster Recovery in PostgreSQL - EQUNIX
Julyanto SUTANDANG
 
Design patterns - Exemples en Java
Design patterns - Exemples en JavaDesign patterns - Exemples en Java
Design patterns - Exemples en Java
Oussama BEN KHIROUN
 
Formation JavaScript full-stack (JS, jQuery, Node.js...)
Formation JavaScript full-stack (JS, jQuery, Node.js...)Formation JavaScript full-stack (JS, jQuery, Node.js...)
Formation JavaScript full-stack (JS, jQuery, Node.js...)
guicara
 

What's hot (20)

Curso de Performance and Tuning - Linux
Curso de Performance and Tuning - LinuxCurso de Performance and Tuning - Linux
Curso de Performance and Tuning - Linux
 
Windows Server 2016: Servidor de DHCP
Windows Server 2016: Servidor de DHCPWindows Server 2016: Servidor de DHCP
Windows Server 2016: Servidor de DHCP
 
ITIL v3 Problem Management
ITIL v3 Problem ManagementITIL v3 Problem Management
ITIL v3 Problem Management
 
Proxysql sharding
Proxysql shardingProxysql sharding
Proxysql sharding
 
Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!
Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!
Engage 2015 - 10 Mistakes You and Every XPages Developer Make. Yes, I said YOU!
 
Mantis Profile & WMS Overview
Mantis Profile & WMS OverviewMantis Profile & WMS Overview
Mantis Profile & WMS Overview
 
MySQL GTID Concepts, Implementation and troubleshooting
MySQL GTID Concepts, Implementation and troubleshooting MySQL GTID Concepts, Implementation and troubleshooting
MySQL GTID Concepts, Implementation and troubleshooting
 
Fundamentos de BI
Fundamentos de BIFundamentos de BI
Fundamentos de BI
 
Support de cours angular
Support de cours angularSupport de cours angular
Support de cours angular
 
OpenNTF Domino API (ODA): Super-Charging Domino Development
OpenNTF Domino API (ODA): Super-Charging Domino DevelopmentOpenNTF Domino API (ODA): Super-Charging Domino Development
OpenNTF Domino API (ODA): Super-Charging Domino Development
 
Best Practices for Configuring Your OSSIM Installation
Best Practices for Configuring Your OSSIM InstallationBest Practices for Configuring Your OSSIM Installation
Best Practices for Configuring Your OSSIM Installation
 
Odoo icon smart buttons
Odoo   icon smart buttonsOdoo   icon smart buttons
Odoo icon smart buttons
 
Conférence: Catalyseurs de l'Intelligence Artificielle et Écosystème des Fram...
Conférence: Catalyseurs de l'Intelligence Artificielle et Écosystème des Fram...Conférence: Catalyseurs de l'Intelligence Artificielle et Écosystème des Fram...
Conférence: Catalyseurs de l'Intelligence Artificielle et Écosystème des Fram...
 
ITIL Introduction
ITIL IntroductionITIL Introduction
ITIL Introduction
 
MySQL InnoDB Cluster and NDB Cluster
MySQL InnoDB Cluster and NDB ClusterMySQL InnoDB Cluster and NDB Cluster
MySQL InnoDB Cluster and NDB Cluster
 
ServiceNow - Introduction.pptx
ServiceNow - Introduction.pptxServiceNow - Introduction.pptx
ServiceNow - Introduction.pptx
 
M|18 How MariaDB Server Scales with Spider
M|18 How MariaDB Server Scales with SpiderM|18 How MariaDB Server Scales with Spider
M|18 How MariaDB Server Scales with Spider
 
High Availability and Disaster Recovery in PostgreSQL - EQUNIX
High Availability and Disaster Recovery in PostgreSQL - EQUNIXHigh Availability and Disaster Recovery in PostgreSQL - EQUNIX
High Availability and Disaster Recovery in PostgreSQL - EQUNIX
 
Design patterns - Exemples en Java
Design patterns - Exemples en JavaDesign patterns - Exemples en Java
Design patterns - Exemples en Java
 
Formation JavaScript full-stack (JS, jQuery, Node.js...)
Formation JavaScript full-stack (JS, jQuery, Node.js...)Formation JavaScript full-stack (JS, jQuery, Node.js...)
Formation JavaScript full-stack (JS, jQuery, Node.js...)
 

Similar to 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 Website
dserrato
 
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
Tim Wright
 
Groke
GrokeGroke
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-templating
Hans 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 MongoDB
Flowdock
 
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 product
joeysim
 
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 Lazy
Maurí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 Go
ikailan
 
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 Chicago
Sumit 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 jQuery
Ross Bruniges
 
Anarchist guide to titanium ui
Anarchist guide to titanium uiAnarchist guide to titanium ui
Anarchist guide to titanium ui
Vincent Baskerville
 
The Third WordPress
The Third WordPressThe Third WordPress
The Third WordPress
Marty Thornley
 
MarkLogic Developer Community Resources, September 2013
MarkLogic Developer Community Resources, September 2013MarkLogic Developer Community Resources, September 2013
MarkLogic Developer Community Resources, September 2013
Eric Bloch
 

Similar to 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
 

Recently uploaded

Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 

Recently uploaded (20)

Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 

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