Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Do pônei ao faraó - Pyramid Web Framework

Do pônei ao faraó - Pyramid Web Framework

Palestra apresentada na Python Brasil [10], mostrando como iniciar com Pyramid, de uma forma "djangomica"

Avatar for Mario Idival

Mario Idival

November 06, 2014

More Decks by Mario Idival

Other Decks in Programming

Transcript

  1. Quem sou eu? • Mario Idival, 22 anos • Desde

    2011 • Python • IFRN - T.A.D.S • AnchorLoans • Pyramid, MongoDB, Angular.js • Django, Rails, PostgreSQL
  2. Instalando Pyramid • WebOb - WSGI request and response objects

    • repoze.lru - is a LRU (least recently used) cache implementation. • zope.interface - This package provides an implementation of "object interfaces" for Python • zope.deprecation - This package provides a simple function called `deprecated(names, reason)` to mark deprecated modules, classes, functions, methods and properties. • venusian - is a library which allows framework authors to defer decorator actions • translationstring - A library used for internationalization (i18n) duties related to translation. • PasteDeploy - Load, configure, and compose WSGI applications and servers
  3. Scaffolds alchemy: Pyramid SQLAlchemy project using url dispatch starter: Pyramid

    starter project zodb: Pyramid ZODB project using traversal pcreate -l command: result:
  4. . !"" CHANGES.txt !"" MANIFEST.in !"" README.txt !"" app1 #

    !"" __init__.py # !"" models.py # !"" scripts # # !"" __init__.py # # %"" initializedb.py # !"" static # # !"" pyramid-16x16.png # # !"" pyramid.png # # !"" theme.css # # %"" theme.min.css # !"" templates # # %"" mytemplate.pt # !"" tests.py # %"" views.py !"" development.ini !"" production.ini %"" setup.py . !"" CHANGES.txt !"" MANIFEST.in !"" README.txt !"" app2 # !"" __init__.py # !"" static # # !"" pyramid-16x16.png # # !"" pyramid.png # # !"" theme.css # # %"" theme.min.css # !"" templates # # %"" mytemplate.pt # !"" tests.py # %"" views.py !"" development.ini !"" production.ini %"" setup.py !"" CHANGES.txt !"" MANIFEST.in !"" README.txt !"" app3 # !"" __init__.py # !"" models.py # !"" static # # !"" pyramid-16x16.png # # !"" pyramid.png # # !"" theme.css # # %"" theme.min.css # !"" templates # # %"" mytemplate.pt # !"" tests.py # %"" views.py !"" development.ini !"" production.ini %"" setup.py pcreate -s alchemy app1 pcreate -s starter app2 pcreate -s zodb app3
  5. • Pyramid • pyramid_chameleon • pyramid_debugtoolbar • pyramid_tm • transaction

    • zope.sqlalchemy • SQLAlchemy • waitress • Pyramid • pyramid_chameleon • pyramid_debugtoolbar • waitress • Pyramid • pyramid_chameleon • pyramid_debugtoolbar • pyramid_tm • transaction • pyramid_zodbconn • ZODB3 • waitress Alchemy Starter ZODB
  6. - Mais sobre - view_config @view_config( route_name=“nome_da_rota”, request_method=“POST”, match_param=“joao”, check_csrf=True,

    renderer=“projeto:app/templates/index.html”, request_param=“info=all”, permission=“nome_da_permissao”, http_cache=3600, xhr=True, ) def view(request): return result # dict
  7. - Mais sobre - view_config 1. renderer = json, string,

    jsonp, template engine • renderer=“projeto:app/templates/index.html” 2. request_method = GET, POST, PUT, DELETE, HEAD • request_method=(“GET”, “DELETE”) • request_method=not_(“GET”)