SlideShare una empresa de Scribd logo
1 de 33
Lighter/faster/better web apps Dylan Jay CTO PretaWeb.com SyPy.org twitter: djay75
From the mind of Chris McDonough As seen in bearded of PyCon 2009 http://www.flickr.com/photos/termie/3392894269/
Pyramid Family Tree Zope   formally Principia (1996-) Zope2   (1998-) BlueBream   formally Zope3 (2004-) ZTK   (2009-)  Repoze.bfg  (2008 – 2010) Pylons   (2005-2010) Pylons Project  (2010-) Pyramid   formally repoze.bfg ( Dec 2010 -) TurboGears (2005-) RoR (2004-) Django (2005-)
Who uses it ,[object Object]
Karl Project
Aeterna Water – paperless sales system ,[object Object]
http://slidesha.re/mH9Lxa
1000 employees
No ORM = easy integrate with Plone
Less Magic. More simple
 
From the minds on PretaWeb... PloneFactory Web installer for the worlds favourite Python CMS Coming 2011...
Differences... ,[object Object]
Component Architecture
Packages (eggs)
Simpler and faster Pyramid Django Plone Not Opinionated Opinionated Structured (CMS) Very Simple Simple Complex No DB ORM Content Types Little Reuse Some Reuse Easy Reuse
Performance http://blog.curiasolutions.com/the-great-web-framework-shootout/
Performance http://plope.com/pyroptimization
Install $  virtualenv  -- no-site-packages  -- distribute  newproject   $  cd newproject   $  bin/pip install pyramid
Hello World from paste.httpserver import serve  from pyramid.configuration import Configurator  from pyramid.response import Response  def hello_world(context, request):  return Response('Hello world!')  if __name__ == '__main__':  config = Configurator()  config.begin()  config.add_view(hello_world)  config.end()  app = config.make_wsgi_app()  serve(app, host='0.0.0.0')
[object Object],Routes (URL Dispatch)
View Callables from pyramid.response import Response def hello_world(request): return Response('Hello world!') from pyramid.httpexceptions import HTTPFound class MyView(object): def __init__(self, request): self.request = request def __call__(self): raise HTTPFound(location='http://example.com')
Request / prefix/foo/bar?pref=red&pref=blue; def hello_world(request): assert 'blue' == request.params['pref'] assert ['red,'blue] == request.params.getall('pref') assert ['foo','bar'] == request.matchdict.values()  return Response('Hello world!')
Renderers from pyramid.view import view_config @view_config(renderer='json') def hello_world(request): return {'content':'Hello!'} @view_config(renderer='string') def hello_world(request): return {'content':'Hello!'} @ view_config(renderer='mypackage:templates/foo.mak') Add your own - config.add_renderer('.jinja2', 'mypackage.MyJinja2Renderer')
Templates from pyramid.renderers import render_to_response def sample_view(request): return render_to_response('templates/foo.pt', {' foo':1, 'bar':2}, request=request)
Templates from pyramid.renderers import render_to_response def sample_view(request): return render_to_response('templates/foo.pt', {' foo':1, 'bar':2}, request=request)
BYO Templating from mako.template import Template from pyramid.response import Response def make_view(request): template = Template(filename='/templates/template.mak') result = template.render(name=request.params['name']) response = Response(result) return response
Chameleon ZPT Templates ,[object Object]
XHTML complaint
.pt files <! DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot; http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;> < html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:tal=&quot;http://xml.zope.org/namespaces/tal&quot;> < head> < meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot; /> < title>${project} Application</title> </ head> < body> < h1 class=&quot;title&quot;>Welcome to <code>${project}</code>, an application generated by the <a Href=”http://...&quot; tal:attributes=”href mylink” > pyramid</a> web application framework.</h1> < ul > <li tal:repeat=”row rows”>${row}</li></ul> </ body> </ html>
Static Assets config.add_static_view(name='static', path='/var/www/static') / static/main.css -> /var/www/static/main.css config.add_static_view(name='static', path='some_package:a/b/c/static') / static/foo.jpg -> ./src/some_package/a/b/c/static/foo.jpg
Traversal
Traversal (Resource Location) Pattern allowing transitive and indirect view loockup Simplifies view code for complex apps Great for content centric URLS config.add_view(photo_edit,  context=Photo, name='edit') Class User(dict): pass Class Folder(dict): pass Class Photo(dict): pass def photo_edit(request): Return Response('editing %s',  request.context.Ttile)

Más contenido relacionado

La actualidad más candente

HTML5 Who what where when why how
HTML5 Who what where when why howHTML5 Who what where when why how
HTML5 Who what where when why how
brucelawson
 

La actualidad más candente (20)

Pyramid Deployment and Maintenance
Pyramid Deployment and MaintenancePyramid Deployment and Maintenance
Pyramid Deployment and Maintenance
 
Take Command of WordPress With WP-CLI at WordCamp Long Beach
Take Command of WordPress With WP-CLI at WordCamp Long BeachTake Command of WordPress With WP-CLI at WordCamp Long Beach
Take Command of WordPress With WP-CLI at WordCamp Long Beach
 
Take Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLITake Command of WordPress With WP-CLI
Take Command of WordPress With WP-CLI
 
Mehr Performance für WordPress - WordCamp Köln
Mehr Performance für WordPress - WordCamp KölnMehr Performance für WordPress - WordCamp Köln
Mehr Performance für WordPress - WordCamp Köln
 
HTML5 Who what where when why how
HTML5 Who what where when why howHTML5 Who what where when why how
HTML5 Who what where when why how
 
Async Tasks with Django Channels
Async Tasks with Django ChannelsAsync Tasks with Django Channels
Async Tasks with Django Channels
 
Pinkoi Platform
Pinkoi PlatformPinkoi Platform
Pinkoi Platform
 
High Performance Web Sites, With Ads: Don't let third parties make you slow
High Performance Web Sites, With Ads: Don't let third parties make you slowHigh Performance Web Sites, With Ads: Don't let third parties make you slow
High Performance Web Sites, With Ads: Don't let third parties make you slow
 
WordPress mit Composer und Git verwalten
WordPress mit Composer und Git verwaltenWordPress mit Composer und Git verwalten
WordPress mit Composer und Git verwalten
 
Real-Time Django
Real-Time DjangoReal-Time Django
Real-Time Django
 
WordPress Performance optimization
WordPress Performance optimizationWordPress Performance optimization
WordPress Performance optimization
 
HTTPS + Let's Encrypt
HTTPS + Let's EncryptHTTPS + Let's Encrypt
HTTPS + Let's Encrypt
 
Doing Things the WordPress Way
Doing Things the WordPress WayDoing Things the WordPress Way
Doing Things the WordPress Way
 
Contributing to WordPress Core - Peter Wilson
Contributing to WordPress Core - Peter WilsonContributing to WordPress Core - Peter Wilson
Contributing to WordPress Core - Peter Wilson
 
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST APIWordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
 
HTML5 multimedia - where we are, where we're going
HTML5 multimedia - where we are, where we're goingHTML5 multimedia - where we are, where we're going
HTML5 multimedia - where we are, where we're going
 
Phing i Fabric - Budowanie i deployment aplikacji webowych
Phing i Fabric - Budowanie i deployment aplikacji webowychPhing i Fabric - Budowanie i deployment aplikacji webowych
Phing i Fabric - Budowanie i deployment aplikacji webowych
 
HTML5 and Accessibility sitting in a tree
HTML5 and Accessibility sitting in a treeHTML5 and Accessibility sitting in a tree
HTML5 and Accessibility sitting in a tree
 
Html5 intro
Html5 introHtml5 intro
Html5 intro
 
Philipp Von Weitershausen Plone Age Mammoths, Sabers And Caveen Cant The...
Philipp Von Weitershausen   Plone Age  Mammoths, Sabers And Caveen   Cant The...Philipp Von Weitershausen   Plone Age  Mammoths, Sabers And Caveen   Cant The...
Philipp Von Weitershausen Plone Age Mammoths, Sabers And Caveen Cant The...
 

Similar a Pyramid Lighter/Faster/Better web apps

Intro to Pylons / Pyramid
Intro to Pylons / PyramidIntro to Pylons / Pyramid
Intro to Pylons / Pyramid
Eric Paxton
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
funkatron
 
Easy Web Project Development & Management with Django & Mercurial
Easy Web Project Development & Management with Django & MercurialEasy Web Project Development & Management with Django & Mercurial
Easy Web Project Development & Management with Django & Mercurial
Widoyo PH
 
Psgi Plack Sfpm
Psgi Plack SfpmPsgi Plack Sfpm
Psgi Plack Sfpm
som_nangia
 
Psgi Plack Sfpm
Psgi Plack SfpmPsgi Plack Sfpm
Psgi Plack Sfpm
wilburlo
 

Similar a Pyramid Lighter/Faster/Better web apps (20)

Building Single Page Application (SPA) with Symfony2 and AngularJS
Building Single Page Application (SPA) with Symfony2 and AngularJSBuilding Single Page Application (SPA) with Symfony2 and AngularJS
Building Single Page Application (SPA) with Symfony2 and AngularJS
 
Intro to Pylons / Pyramid
Intro to Pylons / PyramidIntro to Pylons / Pyramid
Intro to Pylons / Pyramid
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
Building with Firebase
Building with FirebaseBuilding with Firebase
Building with Firebase
 
Software Project Management
Software Project ManagementSoftware Project Management
Software Project Management
 
Django
DjangoDjango
Django
 
Diseño y Desarrollo de APIs
Diseño y Desarrollo de APIsDiseño y Desarrollo de APIs
Diseño y Desarrollo de APIs
 
Python at Facebook
Python at FacebookPython at Facebook
Python at Facebook
 
Quality Use Of Plugin
Quality Use Of PluginQuality Use Of Plugin
Quality Use Of Plugin
 
Easy Web Project Development & Management with Django & Mercurial
Easy Web Project Development & Management with Django & MercurialEasy Web Project Development & Management with Django & Mercurial
Easy Web Project Development & Management with Django & Mercurial
 
Front End Development for Back End Developers - vJUG24 2017
Front End Development for Back End Developers - vJUG24 2017Front End Development for Back End Developers - vJUG24 2017
Front End Development for Back End Developers - vJUG24 2017
 
Mojolicious - A new hope
Mojolicious - A new hopeMojolicious - A new hope
Mojolicious - A new hope
 
PyConMY 2016 Django Channels
PyConMY 2016 Django ChannelsPyConMY 2016 Django Channels
PyConMY 2016 Django Channels
 
Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_Tool
 
Mini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico CesMini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico Ces
 
Psgi Plack Sfpm
Psgi Plack SfpmPsgi Plack Sfpm
Psgi Plack Sfpm
 
Psgi Plack Sfpm
Psgi Plack SfpmPsgi Plack Sfpm
Psgi Plack Sfpm
 
Writing webapps with Perl Dancer
Writing webapps with Perl DancerWriting webapps with Perl Dancer
Writing webapps with Perl Dancer
 
Non Conventional Android Programming (English)
Non Conventional Android Programming (English)Non Conventional Android Programming (English)
Non Conventional Android Programming (English)
 

Más de Dylan Jay

Surviving an earthquake's worth of traffic
Surviving an earthquake's worth of trafficSurviving an earthquake's worth of traffic
Surviving an earthquake's worth of traffic
Dylan Jay
 

Más de Dylan Jay (7)

5 things STILL! TOO! HARD! in Plone 5
5 things STILL! TOO! HARD! in Plone 55 things STILL! TOO! HARD! in Plone 5
5 things STILL! TOO! HARD! in Plone 5
 
Surviving an earthquake's worth of traffic
Surviving an earthquake's worth of trafficSurviving an earthquake's worth of traffic
Surviving an earthquake's worth of traffic
 
Buildout: How to maintain big app stacks without losing your mind
Buildout: How to maintain big app stacks without losing your mindBuildout: How to maintain big app stacks without losing your mind
Buildout: How to maintain big app stacks without losing your mind
 
Opps I deployed it again-ploneconf2010
Opps I deployed it again-ploneconf2010Opps I deployed it again-ploneconf2010
Opps I deployed it again-ploneconf2010
 
Opps i deployed it again
Opps i deployed it againOpps i deployed it again
Opps i deployed it again
 
TestBrowser Driven Development: How to get bulletproof code from lazy developers
TestBrowser Driven Development: How to get bulletproof code from lazy developersTestBrowser Driven Development: How to get bulletproof code from lazy developers
TestBrowser Driven Development: How to get bulletproof code from lazy developers
 
How to host an app for $20 in 20min using buildout and hostout
How to host an app  for $20 in 20min using buildout and hostoutHow to host an app  for $20 in 20min using buildout and hostout
How to host an app for $20 in 20min using buildout and hostout
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
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
 
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
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
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...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
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
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
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
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

Pyramid Lighter/Faster/Better web apps

  • 1. Lighter/faster/better web apps Dylan Jay CTO PretaWeb.com SyPy.org twitter: djay75
  • 2. From the mind of Chris McDonough As seen in bearded of PyCon 2009 http://www.flickr.com/photos/termie/3392894269/
  • 3. Pyramid Family Tree Zope formally Principia (1996-) Zope2 (1998-) BlueBream formally Zope3 (2004-) ZTK (2009-) Repoze.bfg (2008 – 2010) Pylons (2005-2010) Pylons Project (2010-) Pyramid formally repoze.bfg ( Dec 2010 -) TurboGears (2005-) RoR (2004-) Django (2005-)
  • 4.
  • 6.
  • 9. No ORM = easy integrate with Plone
  • 11.  
  • 12. From the minds on PretaWeb... PloneFactory Web installer for the worlds favourite Python CMS Coming 2011...
  • 13.
  • 16. Simpler and faster Pyramid Django Plone Not Opinionated Opinionated Structured (CMS) Very Simple Simple Complex No DB ORM Content Types Little Reuse Some Reuse Easy Reuse
  • 19. Install $ virtualenv -- no-site-packages -- distribute newproject $ cd newproject $ bin/pip install pyramid
  • 20. Hello World from paste.httpserver import serve from pyramid.configuration import Configurator from pyramid.response import Response def hello_world(context, request): return Response('Hello world!') if __name__ == '__main__': config = Configurator() config.begin() config.add_view(hello_world) config.end() app = config.make_wsgi_app() serve(app, host='0.0.0.0')
  • 21.
  • 22. View Callables from pyramid.response import Response def hello_world(request): return Response('Hello world!') from pyramid.httpexceptions import HTTPFound class MyView(object): def __init__(self, request): self.request = request def __call__(self): raise HTTPFound(location='http://example.com')
  • 23. Request / prefix/foo/bar?pref=red&pref=blue; def hello_world(request): assert 'blue' == request.params['pref'] assert ['red,'blue] == request.params.getall('pref') assert ['foo','bar'] == request.matchdict.values() return Response('Hello world!')
  • 24. Renderers from pyramid.view import view_config @view_config(renderer='json') def hello_world(request): return {'content':'Hello!'} @view_config(renderer='string') def hello_world(request): return {'content':'Hello!'} @ view_config(renderer='mypackage:templates/foo.mak') Add your own - config.add_renderer('.jinja2', 'mypackage.MyJinja2Renderer')
  • 25. Templates from pyramid.renderers import render_to_response def sample_view(request): return render_to_response('templates/foo.pt', {' foo':1, 'bar':2}, request=request)
  • 26. Templates from pyramid.renderers import render_to_response def sample_view(request): return render_to_response('templates/foo.pt', {' foo':1, 'bar':2}, request=request)
  • 27. BYO Templating from mako.template import Template from pyramid.response import Response def make_view(request): template = Template(filename='/templates/template.mak') result = template.render(name=request.params['name']) response = Response(result) return response
  • 28.
  • 30. .pt files <! DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot; http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;> < html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:tal=&quot;http://xml.zope.org/namespaces/tal&quot;> < head> < meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot; /> < title>${project} Application</title> </ head> < body> < h1 class=&quot;title&quot;>Welcome to <code>${project}</code>, an application generated by the <a Href=”http://...&quot; tal:attributes=”href mylink” > pyramid</a> web application framework.</h1> < ul > <li tal:repeat=”row rows”>${row}</li></ul> </ body> </ html>
  • 31. Static Assets config.add_static_view(name='static', path='/var/www/static') / static/main.css -> /var/www/static/main.css config.add_static_view(name='static', path='some_package:a/b/c/static') / static/foo.jpg -> ./src/some_package/a/b/c/static/foo.jpg
  • 33. Traversal (Resource Location) Pattern allowing transitive and indirect view loockup Simplifies view code for complex apps Great for content centric URLS config.add_view(photo_edit, context=Photo, name='edit') Class User(dict): pass Class Folder(dict): pass Class Photo(dict): pass def photo_edit(request): Return Response('editing %s', request.context.Ttile)
  • 34. Inside Traversal / joeschmoe/photos/photo1/edit psuedo code: context = get_root()['joeschmoe']['photos']['photo1'] view_callable = get_view(context,'edit') request.context = context view_callable(request)
  • 35.
  • 36. context (class or interface)
  • 40.
  • 41. containment (class or interface)
  • 42. xhr
  • 46. Security - Protecting Authentication Policy – Extract principals from request Authorization Policy – Access based on Context, Principals and View's permissions config.add_view(myview, name='add_entry.html', context='mypackage.resources.Blog', permission='add')
  • 47. Security Configuration def auth(userid, request): return ['user:bob','group:editors'] if userid == 'bob' else None from pyramid.config import Configurator from pyramid.authentication import AuthTktAuthenticationPolicy from pyramid.authorization import ACLAuthorizationPolicy authentication_policy = AuthTktAuthenticationPolicy('seekrit', callback=auth) authorization_policy = ACLAuthorizationPolicy() config = Configurator(authentication_policy=authentication_policy, authorization_policy=authorization_policy)
  • 48. Security - Context from pyramid.security import Everyone from pyramid.security import Allow class Blog(object): pass blog = Blog() blog.__acl__ = [ (Allow, Everyone, 'view'), (Allow, 'group:editors', 'add'), (Allow, 'group:editors', 'edit'), ]
  • 49. Scaffolding $ bin/paster create -t pyramid_starter MyProject $ cd myproj $ ../ bin/python setup.py develop $ ../ bin/paster serve development.ini Starting server in PID 16601. serving on 0.0.0.0:6543 view at http://127.0.0.1:6543 MyProject/ |-- CHANGES.txt |-- development.ini |-- MANIFEST.in |-- myproject | |-- __init__.py | |-- resources.py | |-- static | | |-- favicon.ico | | |-- logo.png | | `-- pylons.css | |-- templates | | `-- mytemplate.pt | |-- tests.py | `-- views.py |-- production.ini |-- README.txt |-- setup.cfg `-- setup.py $ bin/paster create -t pyramid_zodb $ bin/paster create -t pyramid_routesalchemy $ bin/paster create -t pyramid_alchemy
  • 50.
  • 51.
  • 54. Customizing Example def configure_views(config): config.add_view('orig_app.views.theview', name='theview') from pyramid.config import Configurator from orig_app import configure_views if __name == '__main__': config = Configurator() config.include(configure_views) config.add_view('override_app.views.theview', name='theview')
  • 55. pyramid_socketio config.add_route('socket_io', 'socket.io/*remaining') config.add_view(socketio_service, route_name='socket_io') from pyramid.response import Response from pyramid_socketio.io import SocketIOContext, socketio_manage class ConnectIOContext(SocketIOContext): # self.io is the Socket.IO socket # self.request is the request def msg_connect(self, msg): print &quot;Connect message received&quot;, msg self.msg(&quot;connected&quot;, hello=&quot;world&quot;) def socketio_service(request): return Response( socketio_manage(ConnectIOContext(request)) )
  • 56.
  • 57. i18n
  • 59. Hooks
  • 60. ZCML
  • 63.