SlideShare ist ein Scribd-Unternehmen logo
1 von 30
Pylons - An Overview
                         Rapid MVC Web Development with WSGI
                                       Ches Martin
                                    ches.martin@gmail.com




Friday, March 20, 2009
Background
                   What Brought Me Here :




Friday, March 20, 2009
Background
                   What Brought Me Here :
                         •   wanted a rapid-development MVC web
                             framework in a dynamic language




Friday, March 20, 2009
Background
                   What Brought Me Here :
                         •   wanted a rapid-development MVC web
                             framework in a dynamic language
                         •   didn't always like the more quot;opinionatedquot;
                             approaches of the NIH frameworks...




Friday, March 20, 2009
Background
                   What Brought Me Here :
                         •   wanted a rapid-development MVC web
                             framework in a dynamic language
                         •   didn't always like the more quot;opinionatedquot;
                             approaches of the NIH frameworks...
                             •  sometimes convention-over-configuration
                                goes too far




Friday, March 20, 2009
Background
                   What Brought Me Here :
                         •   wanted a rapid-development MVC web
                             framework in a dynamic language
                         •   didn't always like the more quot;opinionatedquot;
                             approaches of the NIH frameworks...
                             •  sometimes convention-over-configuration
                                goes too far
                         •   interested in Python for some time




Friday, March 20, 2009
Background
                   What Brought Me Here :
                         •   wanted a rapid-development MVC web
                             framework in a dynamic language
                         •   didn't always like the more quot;opinionatedquot;
                             approaches of the NIH frameworks...
                             •  sometimes convention-over-configuration
                                goes too far
                         •   interested in Python for some time
                         •   All those fanboys grate on my nerves



Friday, March 20, 2009
Background
                   What Brought Me Here :
                         •   wanted a rapid-development MVC web
                             framework in a dynamic language
                         •   didn't always like the more quot;opinionatedquot;
                             approaches of the NIH frameworks...
                             •  sometimes convention-over-configuration
                                goes too far
                         •   interested in Python for some time
                         •   All those fanboys grate on my nerves
                         •   I'm subversive by nature ;-)


Friday, March 20, 2009
Why Pylons?



Friday, March 20, 2009
What It Is:

                • Flexible, Modular, Extensible
                • Active
                • Largely built on established libraries
                • A community of Python whizzes
                • Forward-thinking
                • The foundation of TurboGears 2.0

Friday, March 20, 2009
What It Isn't




Friday, March 20, 2009
What It Isn't
                • 1.0
                 • The framework components that it builds
                                      -- and sometimes more
                    significantly, the
                         on -- are still moving targets at times




Friday, March 20, 2009
What It Isn't
                • 1.0
                 • The framework components that it builds
                                      -- and sometimes more
                    significantly, the
                           on -- are still moving targets at times
                •        A CMS




Friday, March 20, 2009
What It Isn't
                • 1.0
                 • The framework components that it builds
                                      -- and sometimes more
                    significantly, the
                           on -- are still moving targets at times
                •        A CMS
                •        A cakewalk.
                     •     Fewer decisions made for you -- you’ll
                           spend time learning your way around


Friday, March 20, 2009
A Brief History


                • Who's Who
                • HTML::Mason => Myghty + Paste, dash of
                         Rails => Pylons, Mako, Beaker, etc.




Friday, March 20, 2009
Concepts and Architecture



Friday, March 20, 2009
WSGI
                         (Web Server Gateway Interface)




Friday, March 20, 2009
What is WSGI?
                •        Specifies standard interface between web servers and
                         Python web apps
                •        Goal of decoupling app implementation from specific
                         web servers
                •        PEP 333 - reference implementation in Python 2.5
                         standard lib
                •        quick look at the interface with environ &
                         start_response
                •        Paste (and PasteScript, PasteDeploy)



Friday, March 20, 2009
Why Should You Care
                         About It?
                •        'onion model' of layered, independent middleware
                         components
                     •     implements both “sides” of WSGI spec: looks like an app
                           to a server, and a server to an app
                     •     intercept and transform responses and requests as they
                           move through the chain
                     •     can do exception handling, things like authentication, etc.
                     •     yes, this means you could quot;embedquot; or quot;wrapquot; a Pylons
                           app within another Pylons app



Friday, March 20, 2009
WSGI Hello World
                def my_app(environ, start_response):
                    start_response('200 OK', [('Content-type', 'text/html')])
                    return ['<html><body>Hello World!</body></html>']



                •        start_response() is called with a status code and list of
                         tuple pairs for headers before it returns a value and should
                         be called only once

                •        environ is a dict of CGI-style variables

                •        The response is an iterable




Friday, March 20, 2009
Framework
                         Components
                • URL Dispatch (Routes)
                • Object-Relational Mapper / DB Abstraction
                • Template Engine (Mako)
                • Sessions Management / Caching (Beaker)
                • Form Handling / Validation (FormEncode)
                • WebHelpers

Friday, March 20, 2009
An Example Application



Friday, March 20, 2009
Deploying and
                          Distributing


Friday, March 20, 2009
Deployment Options
                •        The great advantage of eggs / setuptools /
                         PasteDeploy
                •        Paste's http server
                •        mod_wsgi
                •        Twisted
                •        even mod_python, with a WSGI gateway
                •        AJP
                •        Process Control options


Friday, March 20, 2009
Web Service
                               Conveniences
                • Special controllers for REST & XML-RPC
                • map.resource, for generating RESTful routes
                • JSON: simplejson and @jsonify decorator
                • enhanced content negotiation and mimetype
                         support forthcoming in 0.9.7



Friday, March 20, 2009
map.resource (Routes)
        map.resource('message', 'messages')

        # Will setup all the routes as if you had typed the following map commands:
        map.connect('messages', controller='messages', action='create',
            conditions=dict(method=['POST']))
        map.connect('messages', 'messages', controller='messages', action='index',
            conditions=dict(method=['GET']))
        map.connect('formatted_messages', 'messages.:(format)', controller='messages', action='index',
            conditions=dict(method=['GET']))
        map.connect('new_message', 'messages/new', controller='messages', action='new',
            conditions=dict(method=['GET']))
        map.connect('formatted_new_message', 'messages/new.:(format)', controller='messages', action='new',
            conditions=dict(method=['GET']))
        map.connect('messages/:id', controller='messages', action='update',
            conditions=dict(method=['PUT']))
        map.connect('messages/:id', controller='messages', action='delete',
            conditions=dict(method=['DELETE']))
        map.connect('edit_message', 'messages/:(id);edit', controller='messages', action='edit',
            conditions=dict(method=['GET']))
        map.connect('formatted_edit_message', 'messages/:(id).:(format);edit', controller='messages',
            action='edit', conditions=dict(method=['GET']))
        map.connect('message', 'messages/:id', controller='messages', action='show',
            conditions=dict(method=['GET']))
        map.connect('formatted_message', 'messages/:(id).:(format)', controller='messages', action='show',
            conditions=dict(method=['GET']))




Friday, March 20, 2009
Extras

                •        Interactive debugger; ipython for paster shell
                •        Unicode throughout, developers strongly
                         concerned with i18n
                •        Excellent logging framework; Chainsaw
                •        Testing: Nose, paste.fixture's request simulation
                •        Paste templates, scripts; Tesla




Friday, March 20, 2009
Other Extras

                •        Elixir; declarative layer for SQLA following Martin
                         Fowler's Active Record pattern (Rails)
                •        Authkit
                •        ToscaWidgets
                •        doc generation; Pudge, Apydia
                •        Migrate for SQLAlchemy, adminpylon, dbsprockets




Friday, March 20, 2009
Links



Friday, March 20, 2009
Pylons
                •        Home Page:
                           http://pylonshq.com/

                •        IRC:
                            #pylons on irc.freenode.net

                •        Mailing List:
                           http://groups.google.com/group/pylons-discuss

                •        Mercurial (version control):
                           https://www.knowledgetap.com/hg/




Friday, March 20, 2009

Weitere ähnliche Inhalte

Ähnlich wie Pylons - An Overview: Rapid MVC Web Development with WSGI

Portlets
PortletsPortlets
Portletsssetem
 
Introduction to Building Wireframes - Part 2
Introduction to Building Wireframes - Part 2Introduction to Building Wireframes - Part 2
Introduction to Building Wireframes - Part 2lomalogue
 
Keys To World-Class Retail Web Performance - Expert tips for holiday web read...
Keys To World-Class Retail Web Performance - Expert tips for holiday web read...Keys To World-Class Retail Web Performance - Expert tips for holiday web read...
Keys To World-Class Retail Web Performance - Expert tips for holiday web read...SOASTA
 
Getting started with Vue.js - CodeMash 2020
Getting started with Vue.js - CodeMash 2020Getting started with Vue.js - CodeMash 2020
Getting started with Vue.js - CodeMash 2020Burton Smith
 
Samuel Asher Rivello - PureMVC Hands On Part 2
Samuel Asher Rivello - PureMVC Hands On Part 2Samuel Asher Rivello - PureMVC Hands On Part 2
Samuel Asher Rivello - PureMVC Hands On Part 2360|Conferences
 
Web Components: The Future of Web Development is Here
Web Components: The Future of Web Development is HereWeb Components: The Future of Web Development is Here
Web Components: The Future of Web Development is HereJohn Riviello
 
Sugarcoating your frontend one ViewModel at a time
Sugarcoating your frontend one ViewModel at a timeSugarcoating your frontend one ViewModel at a time
Sugarcoating your frontend one ViewModel at a timeEinar Ingebrigtsen
 
Adding a bit of static type checking to a world of web components
Adding a bit of static type checking to a world of web componentsAdding a bit of static type checking to a world of web components
Adding a bit of static type checking to a world of web componentsJordy Moos
 
Speed is Essential for a Great Web Experience
Speed is Essential for a Great Web ExperienceSpeed is Essential for a Great Web Experience
Speed is Essential for a Great Web ExperienceAndy Davies
 
Stefan Judis "Did we(b development) lose the right direction?"
Stefan Judis "Did we(b development) lose the right direction?"Stefan Judis "Did we(b development) lose the right direction?"
Stefan Judis "Did we(b development) lose the right direction?"Fwdays
 
Why Architecture in Web Development matters
Why Architecture in Web Development mattersWhy Architecture in Web Development matters
Why Architecture in Web Development mattersLars Jankowfsky
 
symfony: An Open-Source Framework for Professionals (PHP Day 2008)
symfony: An Open-Source Framework for Professionals (PHP Day 2008)symfony: An Open-Source Framework for Professionals (PHP Day 2008)
symfony: An Open-Source Framework for Professionals (PHP Day 2008)Fabien Potencier
 
Enterprise Portal 2.0
Enterprise Portal 2.0Enterprise Portal 2.0
Enterprise Portal 2.0Jeremi Joslin
 
Design Prototyping: Bringing Wireframes to Life
Design Prototyping: Bringing Wireframes to LifeDesign Prototyping: Bringing Wireframes to Life
Design Prototyping: Bringing Wireframes to Lifegoodfriday
 
Total Browser Pwnag3 V1.0 Public
Total Browser Pwnag3   V1.0 PublicTotal Browser Pwnag3   V1.0 Public
Total Browser Pwnag3 V1.0 PublicRafal Los
 
[Mas 500] Web Basics
[Mas 500] Web Basics[Mas 500] Web Basics
[Mas 500] Web Basicsrahulbot
 
JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...
JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...
JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...Marco Cedaro
 

Ähnlich wie Pylons - An Overview: Rapid MVC Web Development with WSGI (20)

Snakes on the Web
Snakes on the WebSnakes on the Web
Snakes on the Web
 
Portlets
PortletsPortlets
Portlets
 
Introduction to Building Wireframes - Part 2
Introduction to Building Wireframes - Part 2Introduction to Building Wireframes - Part 2
Introduction to Building Wireframes - Part 2
 
Keys To World-Class Retail Web Performance - Expert tips for holiday web read...
Keys To World-Class Retail Web Performance - Expert tips for holiday web read...Keys To World-Class Retail Web Performance - Expert tips for holiday web read...
Keys To World-Class Retail Web Performance - Expert tips for holiday web read...
 
Getting started with Vue.js - CodeMash 2020
Getting started with Vue.js - CodeMash 2020Getting started with Vue.js - CodeMash 2020
Getting started with Vue.js - CodeMash 2020
 
Samuel Asher Rivello - PureMVC Hands On Part 2
Samuel Asher Rivello - PureMVC Hands On Part 2Samuel Asher Rivello - PureMVC Hands On Part 2
Samuel Asher Rivello - PureMVC Hands On Part 2
 
Pole web pp
Pole web ppPole web pp
Pole web pp
 
Web Components: The Future of Web Development is Here
Web Components: The Future of Web Development is HereWeb Components: The Future of Web Development is Here
Web Components: The Future of Web Development is Here
 
Custom V CMS
Custom V CMSCustom V CMS
Custom V CMS
 
Sugarcoating your frontend one ViewModel at a time
Sugarcoating your frontend one ViewModel at a timeSugarcoating your frontend one ViewModel at a time
Sugarcoating your frontend one ViewModel at a time
 
Adding a bit of static type checking to a world of web components
Adding a bit of static type checking to a world of web componentsAdding a bit of static type checking to a world of web components
Adding a bit of static type checking to a world of web components
 
Speed is Essential for a Great Web Experience
Speed is Essential for a Great Web ExperienceSpeed is Essential for a Great Web Experience
Speed is Essential for a Great Web Experience
 
Stefan Judis "Did we(b development) lose the right direction?"
Stefan Judis "Did we(b development) lose the right direction?"Stefan Judis "Did we(b development) lose the right direction?"
Stefan Judis "Did we(b development) lose the right direction?"
 
Why Architecture in Web Development matters
Why Architecture in Web Development mattersWhy Architecture in Web Development matters
Why Architecture in Web Development matters
 
symfony: An Open-Source Framework for Professionals (PHP Day 2008)
symfony: An Open-Source Framework for Professionals (PHP Day 2008)symfony: An Open-Source Framework for Professionals (PHP Day 2008)
symfony: An Open-Source Framework for Professionals (PHP Day 2008)
 
Enterprise Portal 2.0
Enterprise Portal 2.0Enterprise Portal 2.0
Enterprise Portal 2.0
 
Design Prototyping: Bringing Wireframes to Life
Design Prototyping: Bringing Wireframes to LifeDesign Prototyping: Bringing Wireframes to Life
Design Prototyping: Bringing Wireframes to Life
 
Total Browser Pwnag3 V1.0 Public
Total Browser Pwnag3   V1.0 PublicTotal Browser Pwnag3   V1.0 Public
Total Browser Pwnag3 V1.0 Public
 
[Mas 500] Web Basics
[Mas 500] Web Basics[Mas 500] Web Basics
[Mas 500] Web Basics
 
JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...
JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...
JsDay - It's not you, It's me (or how to avoid being coupled with a Javascrip...
 

Kürzlich hochgeladen

Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 

Kürzlich hochgeladen (20)

Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 

Pylons - An Overview: Rapid MVC Web Development with WSGI

  • 1. Pylons - An Overview Rapid MVC Web Development with WSGI Ches Martin ches.martin@gmail.com Friday, March 20, 2009
  • 2. Background What Brought Me Here : Friday, March 20, 2009
  • 3. Background What Brought Me Here : • wanted a rapid-development MVC web framework in a dynamic language Friday, March 20, 2009
  • 4. Background What Brought Me Here : • wanted a rapid-development MVC web framework in a dynamic language • didn't always like the more quot;opinionatedquot; approaches of the NIH frameworks... Friday, March 20, 2009
  • 5. Background What Brought Me Here : • wanted a rapid-development MVC web framework in a dynamic language • didn't always like the more quot;opinionatedquot; approaches of the NIH frameworks... • sometimes convention-over-configuration goes too far Friday, March 20, 2009
  • 6. Background What Brought Me Here : • wanted a rapid-development MVC web framework in a dynamic language • didn't always like the more quot;opinionatedquot; approaches of the NIH frameworks... • sometimes convention-over-configuration goes too far • interested in Python for some time Friday, March 20, 2009
  • 7. Background What Brought Me Here : • wanted a rapid-development MVC web framework in a dynamic language • didn't always like the more quot;opinionatedquot; approaches of the NIH frameworks... • sometimes convention-over-configuration goes too far • interested in Python for some time • All those fanboys grate on my nerves Friday, March 20, 2009
  • 8. Background What Brought Me Here : • wanted a rapid-development MVC web framework in a dynamic language • didn't always like the more quot;opinionatedquot; approaches of the NIH frameworks... • sometimes convention-over-configuration goes too far • interested in Python for some time • All those fanboys grate on my nerves • I'm subversive by nature ;-) Friday, March 20, 2009
  • 10. What It Is: • Flexible, Modular, Extensible • Active • Largely built on established libraries • A community of Python whizzes • Forward-thinking • The foundation of TurboGears 2.0 Friday, March 20, 2009
  • 11. What It Isn't Friday, March 20, 2009
  • 12. What It Isn't • 1.0 • The framework components that it builds -- and sometimes more significantly, the on -- are still moving targets at times Friday, March 20, 2009
  • 13. What It Isn't • 1.0 • The framework components that it builds -- and sometimes more significantly, the on -- are still moving targets at times • A CMS Friday, March 20, 2009
  • 14. What It Isn't • 1.0 • The framework components that it builds -- and sometimes more significantly, the on -- are still moving targets at times • A CMS • A cakewalk. • Fewer decisions made for you -- you’ll spend time learning your way around Friday, March 20, 2009
  • 15. A Brief History • Who's Who • HTML::Mason => Myghty + Paste, dash of Rails => Pylons, Mako, Beaker, etc. Friday, March 20, 2009
  • 17. WSGI (Web Server Gateway Interface) Friday, March 20, 2009
  • 18. What is WSGI? • Specifies standard interface between web servers and Python web apps • Goal of decoupling app implementation from specific web servers • PEP 333 - reference implementation in Python 2.5 standard lib • quick look at the interface with environ & start_response • Paste (and PasteScript, PasteDeploy) Friday, March 20, 2009
  • 19. Why Should You Care About It? • 'onion model' of layered, independent middleware components • implements both “sides” of WSGI spec: looks like an app to a server, and a server to an app • intercept and transform responses and requests as they move through the chain • can do exception handling, things like authentication, etc. • yes, this means you could quot;embedquot; or quot;wrapquot; a Pylons app within another Pylons app Friday, March 20, 2009
  • 20. WSGI Hello World def my_app(environ, start_response): start_response('200 OK', [('Content-type', 'text/html')]) return ['<html><body>Hello World!</body></html>'] • start_response() is called with a status code and list of tuple pairs for headers before it returns a value and should be called only once • environ is a dict of CGI-style variables • The response is an iterable Friday, March 20, 2009
  • 21. Framework Components • URL Dispatch (Routes) • Object-Relational Mapper / DB Abstraction • Template Engine (Mako) • Sessions Management / Caching (Beaker) • Form Handling / Validation (FormEncode) • WebHelpers Friday, March 20, 2009
  • 23. Deploying and Distributing Friday, March 20, 2009
  • 24. Deployment Options • The great advantage of eggs / setuptools / PasteDeploy • Paste's http server • mod_wsgi • Twisted • even mod_python, with a WSGI gateway • AJP • Process Control options Friday, March 20, 2009
  • 25. Web Service Conveniences • Special controllers for REST & XML-RPC • map.resource, for generating RESTful routes • JSON: simplejson and @jsonify decorator • enhanced content negotiation and mimetype support forthcoming in 0.9.7 Friday, March 20, 2009
  • 26. map.resource (Routes) map.resource('message', 'messages') # Will setup all the routes as if you had typed the following map commands: map.connect('messages', controller='messages', action='create', conditions=dict(method=['POST'])) map.connect('messages', 'messages', controller='messages', action='index', conditions=dict(method=['GET'])) map.connect('formatted_messages', 'messages.:(format)', controller='messages', action='index', conditions=dict(method=['GET'])) map.connect('new_message', 'messages/new', controller='messages', action='new', conditions=dict(method=['GET'])) map.connect('formatted_new_message', 'messages/new.:(format)', controller='messages', action='new', conditions=dict(method=['GET'])) map.connect('messages/:id', controller='messages', action='update', conditions=dict(method=['PUT'])) map.connect('messages/:id', controller='messages', action='delete', conditions=dict(method=['DELETE'])) map.connect('edit_message', 'messages/:(id);edit', controller='messages', action='edit', conditions=dict(method=['GET'])) map.connect('formatted_edit_message', 'messages/:(id).:(format);edit', controller='messages', action='edit', conditions=dict(method=['GET'])) map.connect('message', 'messages/:id', controller='messages', action='show', conditions=dict(method=['GET'])) map.connect('formatted_message', 'messages/:(id).:(format)', controller='messages', action='show', conditions=dict(method=['GET'])) Friday, March 20, 2009
  • 27. Extras • Interactive debugger; ipython for paster shell • Unicode throughout, developers strongly concerned with i18n • Excellent logging framework; Chainsaw • Testing: Nose, paste.fixture's request simulation • Paste templates, scripts; Tesla Friday, March 20, 2009
  • 28. Other Extras • Elixir; declarative layer for SQLA following Martin Fowler's Active Record pattern (Rails) • Authkit • ToscaWidgets • doc generation; Pudge, Apydia • Migrate for SQLAlchemy, adminpylon, dbsprockets Friday, March 20, 2009
  • 30. Pylons • Home Page: http://pylonshq.com/ • IRC: #pylons on irc.freenode.net • Mailing List: http://groups.google.com/group/pylons-discuss • Mercurial (version control): https://www.knowledgetap.com/hg/ Friday, March 20, 2009

Hinweis der Redaktion

  1. Disclaimer: I haven't built any sort of large-scale, high-traffic Pylons app, nor gotten rich from it. Hire me and let's build one :-) Thanks for George's coverage of HTTP protocol in his mod_python talk in December
  2. Rails, Django; use existing libraries, please! Reasons of philosophy don't want to bash Django -- all in all I think it's a nice framework and good for Python. I make comparisons because I assume that many are familiar with it Ruby can be a little Perl-like, which should scare you. Also so many DSLs and metaprogramming makes me worry about the Law of Leaky Abstractions...
  3. WSGI to the core, setuptools
  4. The developers of the central pieces are working closely together, and mostly try not to break APIs in major ways Not much in the way of off-the-shelf apps yet. It's not Plone, there are not built-in widgets or a spiffy auto-admin like Django You will spend some time getting familiar with the components and what does what. Fewer decisions are made for you -- flexibility comes at the cost of doing some homework and having ideas about what you want before diving in. As always, use the right tool for the job.
  5. Ben Bangert - Lead Dev, O&#x2019;Reilly Pylons, Routes, Beaker, WebHelpers Mike Bayer - Myghty, Beaker, Mako, SQLAlchemy Ian Bicking - Paste, FormEncode, virtual/workingenv
  6. Flexible deployment options, ability to jump ship to a different server architecture Paste is essentially a WSGI toolkit. Provides conveniences for lower-level WSGI apps or rolling your own framework. Pylons builds on Paste in much the same way that TurboGears 1.0 built on CherryPy.
  7. mostly lifted from Ben Bangert&#x2019;s Google Tech Talk presentation on Pylons and WSGI: http://www.groovie.org/articles/2006/09/18/wsgi-paste-pylons-and-all-that
  8. Pylons includes Routes, also a Ben Bangert project; ported from Rails, but extended and moving in its own directions. Fairly popular outside of Pylons. Briefly compare versus CherryPy/Zope object publishing and Django's regular expressions. Pylons is agnostic, but SQLAlchemy is the overwhelming community favorite. Recipes are available for using Storm, Schevo (pure-Python, non-SQL DBMS), probably Geniusql, CouchDB Pylons default is the excellent Mako, developed by Michael Bayer as a derivation of Myghty's templating system. Buffet-compatible engines are easily swapped in, or used in tandem. This includes Genshi, Cheetah, Kid, Myghty, Jinja (Django-style). XML- or predefined tag-based versus Python-like syntax and inheritance model. Beaker (with Middleware). Caching supported in memory, filesystem and memcached. Signed cookies, and support for cookie-only sessions. FormEncode - validates and coerces to Python types. Touch on form generation / widget tools like ToscaWidgets, FormBuild, FormAlchemy. Helpers for common tasks like text operations (datetime formatting, Textile / Markdown), RSS, and form and URL tags. The latter require Routes and protect your templates from changes in URL structure. Also Javascript integration with Prototype and Scriptaculous, which may eventually disappear from WebHelpers.
  9. In this case we can even show Pylons installation, and suggest it as a best practice Point out that QuickWiki basically uses the default Routes. We can look at more example Routes definitions when discussing map.resource and REST.
  10. setuptools, PasteDeploy how an end user would install and run the app daemon mode, process management options 'entry points' facilitate plugin development Paste HTTP server thread-pooling substitute CherryPy's with one config file directive reverse-proxy with Apache, lighttpd, nginx, etc. Process control Monit, daemontools, supervisord, God
  11. Debug in Wing: wingware.com&#x2014;paste-pylons <http://wingware.com/doc/howtos/paste-pylons> internationalization, and \"smart\" resources that might serve, say, XHTML and JSON
  12. Although recall my concerns about the Law of Leaky Abstractions -- while Elixir may seem simpler, it may actually prove more complex to debug.