Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Pylons - An Overview
                         Rapid MVC Web Development with WSGI
                                       C...
Background
                   What Brought Me Here :




Friday, March 20, 2009
Background
                   What Brought Me Here :
                         •   wanted a rapid-development MVC web
     ...
Background
                   What Brought Me Here :
                         •   wanted a rapid-development MVC web
     ...
Background
                   What Brought Me Here :
                         •   wanted a rapid-development MVC web
     ...
Background
                   What Brought Me Here :
                         •   wanted a rapid-development MVC web
     ...
Background
                   What Brought Me Here :
                         •   wanted a rapid-development MVC web
     ...
Background
                   What Brought Me Here :
                         •   wanted a rapid-development MVC web
     ...
Why Pylons?



Friday, March 20, 2009
What It Is:

                • Flexible, Modular, Extensible
                • Active
                • Largely built on e...
What It Isn't




Friday, March 20, 2009
What It Isn't
                • 1.0
                 • The framework components that it builds
                           ...
What It Isn't
                • 1.0
                 • The framework components that it builds
                           ...
What It Isn't
                • 1.0
                 • The framework components that it builds
                           ...
A Brief History


                • Who's Who
                • HTML::Mason => Myghty + Paste, dash of
                   ...
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...
Why Should You Care
                         About It?
                •        'onion model' of layered, independent midd...
WSGI Hello World
                def my_app(environ, start_response):
                    start_response('200 OK', [('Cont...
Framework
                         Components
                • URL Dispatch (Routes)
                • Object-Relational ...
An Example Application



Friday, March 20, 2009
Deploying and
                          Distributing


Friday, March 20, 2009
Deployment Options
                •        The great advantage of eggs / setuptools /
                         PasteDeplo...
Web Service
                               Conveniences
                • Special controllers for REST & XML-RPC
         ...
map.resource (Routes)
        map.resource('message', 'messages')

        # Will setup all the routes as if you had typed...
Extras

                •        Interactive debugger; ipython for paster shell
                •        Unicode throughou...
Other Extras

                •        Elixir; declarative layer for SQLA following Martin
                         Fowler...
Links



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

                •        IRC:
...
Upcoming SlideShare
Loading in …5
×

Pylons - An Overview: Rapid MVC Web Development with WSGI

3,778 views

Published on

A simple overview of Pylons given at the Cambridge Python Meetup Group in January of '08. From the 0.9.6 era, it's basically outdated by now, but I wanted to archive it on Slideshare.

The complete presentation has a lot of notes. The example application discussed was QuickWiki, the standard Pylons tutorial app.

Published in: Technology
  • Though Pylons is still evolving and was changing a lot as the book was being written, I still find the book pretty comprehensive and digestible, and a huge effort was put into official documentation for Pylons 0.9.7. The state of docs is *far* better than when I gave this presentation a year and a half ago :-)

    Still, I hear this complaint a lot. What specific aspects of learning the framework are troublesome for you? Django sets a standard for documentation that is best-in-class for an open source web framework, I will give them that. The best advice I can give to better grasp Pylons is to hone your Python skills in general.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Pylons - An Overview: Rapid MVC Web Development with WSGI

  1. 1. Pylons - An Overview Rapid MVC Web Development with WSGI Ches Martin ches.martin@gmail.com Friday, March 20, 2009
  2. 2. Background What Brought Me Here : Friday, March 20, 2009
  3. 3. Background What Brought Me Here : • wanted a rapid-development MVC web framework in a dynamic language Friday, March 20, 2009
  4. 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. 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. 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. 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. 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
  9. 9. Why Pylons? Friday, March 20, 2009
  10. 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. 11. What It Isn't Friday, March 20, 2009
  12. 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. 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. 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. 15. A Brief History • Who's Who • HTML::Mason => Myghty + Paste, dash of Rails => Pylons, Mako, Beaker, etc. Friday, March 20, 2009
  16. 16. Concepts and Architecture Friday, March 20, 2009
  17. 17. WSGI (Web Server Gateway Interface) Friday, March 20, 2009
  18. 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. 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. 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. 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
  22. 22. An Example Application Friday, March 20, 2009
  23. 23. Deploying and Distributing Friday, March 20, 2009
  24. 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. 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. 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. 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. 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
  29. 29. Links Friday, March 20, 2009
  30. 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

×