SlideShare ist ein Scribd-Unternehmen logo
1 von 9
Downloaden Sie, um offline zu lesen
Pyramid
Tiny and powerful python web framework
Main Features
Traversal / URLDispatch
ZODB/SQLAlchemy/
NoSQL
LDAP/who/security
Chameleon/Mako/Jinja2
Deform2
Testing
Traversal / URL dispatch
config.add_route(‘route1’, ‘{var1}/{var2}’)
config.add_view(‘module.views.view1’, route_name=‘route1’)
/foo/bar
Object based traversal with a route object
config.add_view(‘module.views.view1’, route_name=‘route1’)
/a/b/c/route1
class Resource(object):
def __init__(self, subobjects):
self.subobjects = subobjects

!
config.add_route('home', '{foo}/{bar}/*traverse',
factory=‘mypackage.routes.root_factory')
/my/first/a/b/c/route1

!

def __getitem__(self, name):
return self.subobjects[name]

root = Resource(
{'a': Resource({'b': Resource({'c': Resource({})})})}
)

!

def root_factory(request):
return root
Strong add-ons
Cornice - REST web services
Kotti - CMS
Kombu/pika - RabbitMQ integration
Pyramid_soquetio - SoquetIO integration
pymongo/mongopersist - MongoDB integration
SubstanceD - App server
MongoPersist
class Person(persistent.Persistent, ReprMixin):
...
... def __init__(self, name, phone=None, address=None, friends=None,
...
visited=(), birthday=None):
...
self.name = name
...
self.address = address
...
self.friends = friends or {}
...
self.visited = visited
...
self.phone = phone
...
self.birthday = birthday
...
self.today = datetime.datetime.now()
...
... def __str__(self):
...
return self.name
Cornice
users = Service(name='users', path='/users', description=“Users")

!

@users.get(validators=valid_token)
def get_users(request):
"""Returns a list of all users."""
return {'users': _USERS.keys()}

!

@users.post(validators=unique)
def create_user(request):
"""Adds a new user."""
user = request.validated['user']
_USERS[user['name']] = user['token']
return {'token': '%s-%s' % (user['name'], user['token'])}
“How to write a modern app with Pyramid”

With modern JS Frameworks
MONGODB

PYRAMID

ANGULART/BACKBONE

PYRAMID
CORNICE

REST

Tempus
Questions ?
Ramon Navarro Bosch - r.navarro@iskra.cat

Weitere ähnliche Inhalte

Was ist angesagt?

CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложенияCodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest
 
Functional programming using underscorejs
Functional programming using underscorejsFunctional programming using underscorejs
Functional programming using underscorejs
偉格 高
 

Was ist angesagt? (20)

CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложенияCodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
 
Templating in ansible
Templating in ansibleTemplating in ansible
Templating in ansible
 
Ansible 202
Ansible 202Ansible 202
Ansible 202
 
Datagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and BackgridDatagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and Backgrid
 
Groovy Grails Gr8Ladies Women Techmakers: Minneapolis
Groovy Grails Gr8Ladies Women Techmakers: MinneapolisGroovy Grails Gr8Ladies Women Techmakers: Minneapolis
Groovy Grails Gr8Ladies Women Techmakers: Minneapolis
 
Variable precedence: Where should I put a variable?
Variable precedence: Where should I put a variable?Variable precedence: Where should I put a variable?
Variable precedence: Where should I put a variable?
 
Using the new WordPress REST API
Using the new WordPress REST APIUsing the new WordPress REST API
Using the new WordPress REST API
 
Backbone页面路由技术分析与实例
Backbone页面路由技术分析与实例Backbone页面路由技术分析与实例
Backbone页面路由技术分析与实例
 
Codeigniter : Using Third Party Components - Zend Framework Components
Codeigniter : Using Third Party Components - Zend Framework ComponentsCodeigniter : Using Third Party Components - Zend Framework Components
Codeigniter : Using Third Party Components - Zend Framework Components
 
Ruby Kaigi 2008 LT
Ruby Kaigi 2008 LTRuby Kaigi 2008 LT
Ruby Kaigi 2008 LT
 
Introduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress DevelopersIntroduction to AngularJS For WordPress Developers
Introduction to AngularJS For WordPress Developers
 
Connecting Content Silos: One CMS, Many Sites With The WordPress REST API
 Connecting Content Silos: One CMS, Many Sites With The WordPress REST API Connecting Content Silos: One CMS, Many Sites With The WordPress REST API
Connecting Content Silos: One CMS, Many Sites With The WordPress REST API
 
Functional programming using underscorejs
Functional programming using underscorejsFunctional programming using underscorejs
Functional programming using underscorejs
 
App Lego
App LegoApp Lego
App Lego
 
Config Management with MicroOperators
Config Management with MicroOperatorsConfig Management with MicroOperators
Config Management with MicroOperators
 
CakePHP + PostgreSQL
CakePHP + PostgreSQLCakePHP + PostgreSQL
CakePHP + PostgreSQL
 
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
 
Extending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh PollockExtending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh Pollock
 
this
thisthis
this
 
Javascript essential-pattern
Javascript essential-patternJavascript essential-pattern
Javascript essential-pattern
 

Andere mochten auch

5 Reasons Why Your Podcast Sucks On Itunes
5 Reasons Why Your Podcast Sucks On Itunes5 Reasons Why Your Podcast Sucks On Itunes
5 Reasons Why Your Podcast Sucks On Itunes
Evo Terra
 
powerpoint Layouts for reuse
powerpoint Layouts for reusepowerpoint Layouts for reuse
powerpoint Layouts for reuse
barcelona99
 
Jane Chyun Vocab The True Confession Of Charlotte Doyle
Jane Chyun   Vocab The True Confession Of Charlotte DoyleJane Chyun   Vocab The True Confession Of Charlotte Doyle
Jane Chyun Vocab The True Confession Of Charlotte Doyle
jane940325
 
Cloud hosting today
Cloud hosting todayCloud hosting today
Cloud hosting today
Combell NV
 
Spring 5.1 Words of Encouragement
Spring 5.1 Words of EncouragementSpring 5.1 Words of Encouragement
Spring 5.1 Words of Encouragement
chrissienehrenberg
 
Graduate Design - Nutrient
Graduate Design - NutrientGraduate Design - Nutrient
Graduate Design - Nutrient
Haoxiang Shen
 
Upshot 2015 trend_slrgprt
Upshot 2015 trend_slrgprtUpshot 2015 trend_slrgprt
Upshot 2015 trend_slrgprt
Liz Aviles
 
The Reflection Pool
The Reflection PoolThe Reflection Pool
The Reflection Pool
Mrs. McCabe
 

Andere mochten auch (20)

Pyramid Deployment and Maintenance
Pyramid Deployment and MaintenancePyramid Deployment and Maintenance
Pyramid Deployment and Maintenance
 
Old Vs New A New Approach To A Mobile Classroom
Old Vs New A New Approach To A Mobile ClassroomOld Vs New A New Approach To A Mobile Classroom
Old Vs New A New Approach To A Mobile Classroom
 
Cafè amb web
Cafè amb webCafè amb web
Cafè amb web
 
5 Reasons Why Your Podcast Sucks On Itunes
5 Reasons Why Your Podcast Sucks On Itunes5 Reasons Why Your Podcast Sucks On Itunes
5 Reasons Why Your Podcast Sucks On Itunes
 
Neil's Birthday Present
Neil's Birthday PresentNeil's Birthday Present
Neil's Birthday Present
 
Poetic Landscapes
Poetic LandscapesPoetic Landscapes
Poetic Landscapes
 
The Ant
The AntThe Ant
The Ant
 
powerpoint Layouts for reuse
powerpoint Layouts for reusepowerpoint Layouts for reuse
powerpoint Layouts for reuse
 
Jane Chyun Vocab The True Confession Of Charlotte Doyle
Jane Chyun   Vocab The True Confession Of Charlotte DoyleJane Chyun   Vocab The True Confession Of Charlotte Doyle
Jane Chyun Vocab The True Confession Of Charlotte Doyle
 
Cloud hosting today
Cloud hosting todayCloud hosting today
Cloud hosting today
 
11 tips om in de Cloud te raken en er niet uit te vallen
11 tips om in de Cloud te raken en er niet uit te vallen11 tips om in de Cloud te raken en er niet uit te vallen
11 tips om in de Cloud te raken en er niet uit te vallen
 
Infancia e-educacao pps
Infancia e-educacao ppsInfancia e-educacao pps
Infancia e-educacao pps
 
Spring 5.1 Words of Encouragement
Spring 5.1 Words of EncouragementSpring 5.1 Words of Encouragement
Spring 5.1 Words of Encouragement
 
Mohenjo Daro
Mohenjo DaroMohenjo Daro
Mohenjo Daro
 
Mohenjo Daro
Mohenjo DaroMohenjo Daro
Mohenjo Daro
 
Educazione secondo Joanna de Angelis
Educazione secondo Joanna de AngelisEducazione secondo Joanna de Angelis
Educazione secondo Joanna de Angelis
 
Graduate Design - Nutrient
Graduate Design - NutrientGraduate Design - Nutrient
Graduate Design - Nutrient
 
Upshot 2015 trend_slrgprt
Upshot 2015 trend_slrgprtUpshot 2015 trend_slrgprt
Upshot 2015 trend_slrgprt
 
Roller Coasters
Roller CoastersRoller Coasters
Roller Coasters
 
The Reflection Pool
The Reflection PoolThe Reflection Pool
The Reflection Pool
 

Ähnlich wie Pyramid

JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
David Padbury
 
Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)
Fabien Potencier
 
BlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorksBlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorks
mwbrooks
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
Nick Sieger
 
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docxcase3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
tidwellveronique
 

Ähnlich wie Pyramid (20)

DevOps with Fabric
DevOps with FabricDevOps with Fabric
DevOps with Fabric
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
Codeigniter : Custom Routing - Manipulate Uri
Codeigniter : Custom Routing - Manipulate UriCodeigniter : Custom Routing - Manipulate Uri
Codeigniter : Custom Routing - Manipulate Uri
 
Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)
 
Good karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaGood karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with Karma
 
BlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorksBlackBerry DevCon 2011 - PhoneGap and WebWorks
BlackBerry DevCon 2011 - PhoneGap and WebWorks
 
Pyramid Framework
Pyramid FrameworkPyramid Framework
Pyramid Framework
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
 
Django Vs Rails
Django Vs RailsDjango Vs Rails
Django Vs Rails
 
Groovy - Grails as a modern scripting language for Web applications
Groovy - Grails as a modern scripting language for Web applicationsGroovy - Grails as a modern scripting language for Web applications
Groovy - Grails as a modern scripting language for Web applications
 
Advanced symfony Techniques
Advanced symfony TechniquesAdvanced symfony Techniques
Advanced symfony Techniques
 
Iktomi lightning talk
Iktomi lightning talkIktomi lightning talk
Iktomi lightning talk
 
Advanced javascript
Advanced javascriptAdvanced javascript
Advanced javascript
 
Drupal 8, Where Did the Code Go? From Info Hook to Plugin
Drupal 8, Where Did the Code Go? From Info Hook to PluginDrupal 8, Where Did the Code Go? From Info Hook to Plugin
Drupal 8, Where Did the Code Go? From Info Hook to Plugin
 
Rapid prototyping and easy testing with ember cli mirage
Rapid prototyping and easy testing with ember cli mirageRapid prototyping and easy testing with ember cli mirage
Rapid prototyping and easy testing with ember cli mirage
 
Director x Backbone = :)
Director x Backbone = :)Director x Backbone = :)
Director x Backbone = :)
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
 
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docxcase3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
 
How Does Kubernetes Build OpenAPI Specifications?
How Does Kubernetes Build OpenAPI Specifications?How Does Kubernetes Build OpenAPI Specifications?
How Does Kubernetes Build OpenAPI Specifications?
 
OSCON - ES6 metaprogramming unleashed
OSCON -  ES6 metaprogramming unleashedOSCON -  ES6 metaprogramming unleashed
OSCON - ES6 metaprogramming unleashed
 

Mehr von Ramon Navarro

Multilingual sites in plone
Multilingual sites in ploneMultilingual sites in plone
Multilingual sites in plone
Ramon Navarro
 

Mehr von Ramon Navarro (11)

Guillotina
GuillotinaGuillotina
Guillotina
 
Pipelines for model deployment
Pipelines for model deploymentPipelines for model deployment
Pipelines for model deployment
 
Plone server
Plone serverPlone server
Plone server
 
How containers helped a SaaS startup be developed and go live
How containers helped a SaaS startup be developed and go liveHow containers helped a SaaS startup be developed and go live
How containers helped a SaaS startup be developed and go live
 
Plone 5 and machine learning
Plone 5 and machine learningPlone 5 and machine learning
Plone 5 and machine learning
 
CI on large open source software : Plone & Plone 5 is here!
CI on large open source software : Plone & Plone 5 is here!CI on large open source software : Plone & Plone 5 is here!
CI on large open source software : Plone & Plone 5 is here!
 
Resource registries plone conf 2014
Resource registries plone conf 2014Resource registries plone conf 2014
Resource registries plone conf 2014
 
Multilingual sites in plone
Multilingual sites in ploneMultilingual sites in plone
Multilingual sites in plone
 
Presentacio meetup Python BCN
Presentacio meetup Python BCNPresentacio meetup Python BCN
Presentacio meetup Python BCN
 
plone.app.multilingual
plone.app.multilingual plone.app.multilingual
plone.app.multilingual
 
WPD Barcelona 2008 Què és Plone ?
WPD Barcelona 2008 Què és Plone ?WPD Barcelona 2008 Què és Plone ?
WPD Barcelona 2008 Què és Plone ?
 

Pyramid

  • 1. Pyramid Tiny and powerful python web framework
  • 2. Main Features Traversal / URLDispatch ZODB/SQLAlchemy/ NoSQL LDAP/who/security Chameleon/Mako/Jinja2 Deform2 Testing
  • 3. Traversal / URL dispatch config.add_route(‘route1’, ‘{var1}/{var2}’) config.add_view(‘module.views.view1’, route_name=‘route1’) /foo/bar Object based traversal with a route object config.add_view(‘module.views.view1’, route_name=‘route1’) /a/b/c/route1 class Resource(object): def __init__(self, subobjects): self.subobjects = subobjects ! config.add_route('home', '{foo}/{bar}/*traverse', factory=‘mypackage.routes.root_factory') /my/first/a/b/c/route1 ! def __getitem__(self, name): return self.subobjects[name] root = Resource( {'a': Resource({'b': Resource({'c': Resource({})})})} ) ! def root_factory(request): return root
  • 4. Strong add-ons Cornice - REST web services Kotti - CMS Kombu/pika - RabbitMQ integration Pyramid_soquetio - SoquetIO integration pymongo/mongopersist - MongoDB integration SubstanceD - App server
  • 5. MongoPersist class Person(persistent.Persistent, ReprMixin): ... ... def __init__(self, name, phone=None, address=None, friends=None, ... visited=(), birthday=None): ... self.name = name ... self.address = address ... self.friends = friends or {} ... self.visited = visited ... self.phone = phone ... self.birthday = birthday ... self.today = datetime.datetime.now() ... ... def __str__(self): ... return self.name
  • 6. Cornice users = Service(name='users', path='/users', description=“Users") ! @users.get(validators=valid_token) def get_users(request): """Returns a list of all users.""" return {'users': _USERS.keys()} ! @users.post(validators=unique) def create_user(request): """Adds a new user.""" user = request.validated['user'] _USERS[user['name']] = user['token'] return {'token': '%s-%s' % (user['name'], user['token'])}
  • 7. “How to write a modern app with Pyramid” With modern JS Frameworks
  • 9. Questions ? Ramon Navarro Bosch - r.navarro@iskra.cat