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.

Intro to Pylons / Pyramid


Published on

Published in: Technology
  • Be the first to comment

Intro to Pylons / Pyramid

  1. 1.
  2. 2.  Gives you some exposure to web frameworks in general and how they work. Exposes some of the magic that some frameworks like Rails do for you. It might make you better, but time will tell.
  3. 3.  Pylons was merged with repoze.bfg ( Pylons is actually not in development any longer, but maintained beside Pyramid. “Only pay for what you eat” philosophy
  4. 4.  I used ‘pip’ (http://www.pip- $ pip install pyramid You will also need to install SQLAlchemy $ pip install SQLAlchemy
  5. 5.  $ pcreate –s alchemy myappname
  6. 6.  See in the root of your application Installing your app $ pip install –e . Installing a forked app $ python
  7. 7.  Models for a Pyramid application are stored in a file called /models/ It creates a class called MyModel for you. You can delete it.class MyModel(Base): __tablename__ = models id = Column(Integer, primary_key=True) name = Column(Text, unique=True) value = Column(Integer)def __init__(self, name, value): = name self.value = value
  8. 8.  Create all of your models in /models/ Similar to Django
  9. 9.  Routes are defined in in the app rootconfig.add_route(blog, /blog/{id:d+}/{slug})config.add_route(blog_action, /blog/{action})config.add_route(auth, /sign/{action})
  10. 10.  You can map urls to your views using the file Use @view_config() decorator for each route@view_config(route_name=home, renderer=blog:templates/index.mako)
  11. 11.  The default templating engine is Mako ( Syntax % for row in row: ${makerow(row)} % endfor <% def name=“makerow(row)”> % for name in row: <p>${name}</p> % endfor </def>
  12. 12.  Addons officially endorsed: pyramid.html#pyramid-add-on- documentation Add it to your file Then run $ python develop May need to pip install the add on first
  13. 13. $ git clone$ python develop$ initialize_pyramid_blogr_db development.ini$ pserve --reload development.ini