SlideShare ist ein Scribd-Unternehmen logo
1 von 61
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

Preparing for Deployment of SAP Ariba Solutions at Your Company
Preparing for Deployment of SAP Ariba Solutions at Your Company	Preparing for Deployment of SAP Ariba Solutions at Your Company
Preparing for Deployment of SAP Ariba Solutions at Your Company SAP Ariba
 
Servicenow overview
Servicenow overviewServicenow overview
Servicenow overviewCloudSyntrix
 
Replacing Your Shared Drive with Alfresco - Open Source ECM
Replacing Your Shared Drive with Alfresco - Open Source ECMReplacing Your Shared Drive with Alfresco - Open Source ECM
Replacing Your Shared Drive with Alfresco - Open Source ECMAlfresco Software
 
Aggregating API Services with an API Gateway (BFF)
Aggregating API Services with an API Gateway (BFF)Aggregating API Services with an API Gateway (BFF)
Aggregating API Services with an API Gateway (BFF)José Roberto Araújo
 
FinOps for private cloud
FinOps for private cloudFinOps for private cloud
FinOps for private cloudAlexander Tokarev
 
Achieve Digital Transformation with SAP Hybris Commerce Travel Accelerator
Achieve Digital Transformation with SAP Hybris Commerce Travel AcceleratorAchieve Digital Transformation with SAP Hybris Commerce Travel Accelerator
Achieve Digital Transformation with SAP Hybris Commerce Travel AcceleratorSAP Customer Experience
 
Microservices Architecture - Bangkok 2018
Microservices Architecture - Bangkok 2018Microservices Architecture - Bangkok 2018
Microservices Architecture - Bangkok 2018Araf Karsh Hamid
 
What, Why and How of Governance in RPA
What, Why and How of Governance  in RPAWhat, Why and How of Governance  in RPA
What, Why and How of Governance in RPAMohit Sharma (GAICD)
 
Transform Procurement with the SAP S/4HANA Digital Core and SAP Ariba Solutions
Transform Procurement with the SAP S/4HANA Digital Core and SAP Ariba SolutionsTransform Procurement with the SAP S/4HANA Digital Core and SAP Ariba Solutions
Transform Procurement with the SAP S/4HANA Digital Core and SAP Ariba SolutionsSAP Ariba
 
Discover SAP BusinessObjects BI 4.3 SP03
Discover SAP BusinessObjects BI 4.3 SP03Discover SAP BusinessObjects BI 4.3 SP03
Discover SAP BusinessObjects BI 4.3 SP03Wiiisdom
 
Digital Core Transformation - SAP S/4HANA
Digital Core Transformation - SAP S/4HANADigital Core Transformation - SAP S/4HANA
Digital Core Transformation - SAP S/4HANADeloitte Switzerland
 
Getting started with SAP PI/PO an overview presentation
Getting started with SAP PI/PO an overview presentationGetting started with SAP PI/PO an overview presentation
Getting started with SAP PI/PO an overview presentationFigaf.com
 
Azure Functions Real World Examples
Azure Functions Real World Examples Azure Functions Real World Examples
Azure Functions Real World Examples Yochay Kiriaty
 
Azure API Management
Azure API ManagementAzure API Management
Azure API ManagementDaniel Toomey
 
Why API Ops is the Next Wave of DevOps
Why API Ops is the Next Wave of DevOpsWhy API Ops is the Next Wave of DevOps
Why API Ops is the Next Wave of DevOpsJohn Musser
 

Was ist angesagt? (20)

Focused build overview
Focused build overviewFocused build overview
Focused build overview
 
Preparing for Deployment of SAP Ariba Solutions at Your Company
Preparing for Deployment of SAP Ariba Solutions at Your Company	Preparing for Deployment of SAP Ariba Solutions at Your Company
Preparing for Deployment of SAP Ariba Solutions at Your Company
 
Servicenow overview
Servicenow overviewServicenow overview
Servicenow overview
 
Replacing Your Shared Drive with Alfresco - Open Source ECM
Replacing Your Shared Drive with Alfresco - Open Source ECMReplacing Your Shared Drive with Alfresco - Open Source ECM
Replacing Your Shared Drive with Alfresco - Open Source ECM
 
Aggregating API Services with an API Gateway (BFF)
Aggregating API Services with an API Gateway (BFF)Aggregating API Services with an API Gateway (BFF)
Aggregating API Services with an API Gateway (BFF)
 
FinOps for private cloud
FinOps for private cloudFinOps for private cloud
FinOps for private cloud
 
Sap fiori
Sap fioriSap fiori
Sap fiori
 
Oracle soa suite 12c
Oracle soa suite 12cOracle soa suite 12c
Oracle soa suite 12c
 
Achieve Digital Transformation with SAP Hybris Commerce Travel Accelerator
Achieve Digital Transformation with SAP Hybris Commerce Travel AcceleratorAchieve Digital Transformation with SAP Hybris Commerce Travel Accelerator
Achieve Digital Transformation with SAP Hybris Commerce Travel Accelerator
 
Permissions level in SPO
Permissions level in SPOPermissions level in SPO
Permissions level in SPO
 
Microservices Architecture - Bangkok 2018
Microservices Architecture - Bangkok 2018Microservices Architecture - Bangkok 2018
Microservices Architecture - Bangkok 2018
 
What, Why and How of Governance in RPA
What, Why and How of Governance  in RPAWhat, Why and How of Governance  in RPA
What, Why and How of Governance in RPA
 
Transform Procurement with the SAP S/4HANA Digital Core and SAP Ariba Solutions
Transform Procurement with the SAP S/4HANA Digital Core and SAP Ariba SolutionsTransform Procurement with the SAP S/4HANA Digital Core and SAP Ariba Solutions
Transform Procurement with the SAP S/4HANA Digital Core and SAP Ariba Solutions
 
Discover SAP BusinessObjects BI 4.3 SP03
Discover SAP BusinessObjects BI 4.3 SP03Discover SAP BusinessObjects BI 4.3 SP03
Discover SAP BusinessObjects BI 4.3 SP03
 
How Secure Are Your APIs?
How Secure Are Your APIs?How Secure Are Your APIs?
How Secure Are Your APIs?
 
Digital Core Transformation - SAP S/4HANA
Digital Core Transformation - SAP S/4HANADigital Core Transformation - SAP S/4HANA
Digital Core Transformation - SAP S/4HANA
 
Getting started with SAP PI/PO an overview presentation
Getting started with SAP PI/PO an overview presentationGetting started with SAP PI/PO an overview presentation
Getting started with SAP PI/PO an overview presentation
 
Azure Functions Real World Examples
Azure Functions Real World Examples Azure Functions Real World Examples
Azure Functions Real World Examples
 
Azure API Management
Azure API ManagementAzure API Management
Azure API Management
 
Why API Ops is the Next Wave of DevOps
Why API Ops is the Next Wave of DevOpsWhy API Ops is the Next Wave of DevOps
Why API Ops is the Next Wave of DevOps
 

Ă„hnlich wie 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
 
Anarchist guide to titanium ui
Anarchist guide to titanium uiAnarchist guide to titanium ui
Anarchist guide to titanium uiVincent Baskerville
 
The Third WordPress
The Third WordPressThe Third WordPress
The Third WordPressMarty Thornley
 
MarkLogic Developer Community Resources, September 2013
MarkLogic Developer Community Resources, September 2013MarkLogic Developer Community Resources, September 2013
MarkLogic Developer Community Resources, September 2013Eric Bloch
 

Ă„hnlich wie 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
 

KĂĽrzlich hochgeladen

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
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
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
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
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Christopher Logan Kennedy
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 

KĂĽrzlich hochgeladen (20)

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
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
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
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...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

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