SlideShare a Scribd company logo
1 of 61
Download to read offline
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

인수테스트 주도 개발
인수테스트 주도 개발인수테스트 주도 개발
인수테스트 주도 개발Jaehoon Oh
 
Integration Testing with a Citrus twist
Integration Testing with a Citrus twistIntegration Testing with a Citrus twist
Integration Testing with a Citrus twistchristophd
 
Selenium with Cucumber
Selenium  with Cucumber Selenium  with Cucumber
Selenium with Cucumber Knoldus Inc.
 
Supervisord 사용법을 간단히 알아보자!
Supervisord 사용법을 간단히 알아보자!Supervisord 사용법을 간단히 알아보자!
Supervisord 사용법을 간단히 알아보자!Kwangsik Lee
 
Getting Started with Spring Authorization Server
Getting Started with Spring Authorization ServerGetting Started with Spring Authorization Server
Getting Started with Spring Authorization ServerVMware Tanzu
 
Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023
Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023
Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023Sam Brannen
 
Java EE Introduction
Java EE IntroductionJava EE Introduction
Java EE Introductionejlp12
 
Robot Framework Dos And Don'ts
Robot Framework Dos And Don'tsRobot Framework Dos And Don'ts
Robot Framework Dos And Don'tsPekka Klärck
 
Jenkins for java world
Jenkins for java worldJenkins for java world
Jenkins for java worldAshok Kumar
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - CoreDzmitry Naskou
 
Always On - Les solutions de haute disponibilité avec SQL Server 2012
Always On - Les solutions de haute disponibilité avec SQL Server 2012Always On - Les solutions de haute disponibilité avec SQL Server 2012
Always On - Les solutions de haute disponibilité avec SQL Server 2012Microsoft Technet France
 
ESB Presentation
ESB PresentationESB Presentation
ESB PresentationF K
 
[오픈소스컨설팅] ARM & OpenStack Community
[오픈소스컨설팅] ARM & OpenStack Community[오픈소스컨설팅] ARM & OpenStack Community
[오픈소스컨설팅] ARM & OpenStack CommunityOpen Source Consulting
 
Move SysML models from Rhapsody to MagicDraw with the Publisher for Rhapsody
Move SysML models from Rhapsody to MagicDraw with the Publisher for Rhapsody Move SysML models from Rhapsody to MagicDraw with the Publisher for Rhapsody
Move SysML models from Rhapsody to MagicDraw with the Publisher for Rhapsody SodiusWillert
 
Hybrid Automation Framework Development introduction
Hybrid Automation Framework Development introductionHybrid Automation Framework Development introduction
Hybrid Automation Framework Development introductionGanuka Yashantha
 
Fast DDS Features & Tools
Fast DDS Features & ToolsFast DDS Features & Tools
Fast DDS Features & ToolseProsima
 

What's hot (20)

Automated Test Framework with Cucumber
Automated Test Framework with CucumberAutomated Test Framework with Cucumber
Automated Test Framework with Cucumber
 
인수테스트 주도 개발
인수테스트 주도 개발인수테스트 주도 개발
인수테스트 주도 개발
 
Integration Testing with a Citrus twist
Integration Testing with a Citrus twistIntegration Testing with a Citrus twist
Integration Testing with a Citrus twist
 
Selenium with Cucumber
Selenium  with Cucumber Selenium  with Cucumber
Selenium with Cucumber
 
Supervisord 사용법을 간단히 알아보자!
Supervisord 사용법을 간단히 알아보자!Supervisord 사용법을 간단히 알아보자!
Supervisord 사용법을 간단히 알아보자!
 
Automation Testing & TDD
Automation Testing & TDDAutomation Testing & TDD
Automation Testing & TDD
 
Getting Started with Spring Authorization Server
Getting Started with Spring Authorization ServerGetting Started with Spring Authorization Server
Getting Started with Spring Authorization Server
 
Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023
Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023
Testing with Spring, AOT, GraalVM, and JUnit 5 - Spring I/O 2023
 
Java EE Introduction
Java EE IntroductionJava EE Introduction
Java EE Introduction
 
Robot Framework Dos And Don'ts
Robot Framework Dos And Don'tsRobot Framework Dos And Don'ts
Robot Framework Dos And Don'ts
 
Jenkins for java world
Jenkins for java worldJenkins for java world
Jenkins for java world
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 
Always On - Les solutions de haute disponibilité avec SQL Server 2012
Always On - Les solutions de haute disponibilité avec SQL Server 2012Always On - Les solutions de haute disponibilité avec SQL Server 2012
Always On - Les solutions de haute disponibilité avec SQL Server 2012
 
ESB Presentation
ESB PresentationESB Presentation
ESB Presentation
 
Netflix conductor
Netflix conductorNetflix conductor
Netflix conductor
 
[오픈소스컨설팅] ARM & OpenStack Community
[오픈소스컨설팅] ARM & OpenStack Community[오픈소스컨설팅] ARM & OpenStack Community
[오픈소스컨설팅] ARM & OpenStack Community
 
Move SysML models from Rhapsody to MagicDraw with the Publisher for Rhapsody
Move SysML models from Rhapsody to MagicDraw with the Publisher for Rhapsody Move SysML models from Rhapsody to MagicDraw with the Publisher for Rhapsody
Move SysML models from Rhapsody to MagicDraw with the Publisher for Rhapsody
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
 
Hybrid Automation Framework Development introduction
Hybrid Automation Framework Development introductionHybrid Automation Framework Development introduction
Hybrid Automation Framework Development introduction
 
Fast DDS Features & Tools
Fast DDS Features & ToolsFast DDS Features & Tools
Fast DDS Features & Tools
 

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

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

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 

Recently uploaded (20)

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 

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