0
http://www.pylonsproject.org
   Gives you some exposure to web frameworks    in general and how they work.   Exposes some of the magic that some    f...
   Pylons was merged with repoze.bfg    (http://bfg.repoze.org)   Pylons is actually not in development any    longer, b...
   I used ‘pip’ (http://www.pip-    installer.org/en/latest/)   $ pip install pyramid   You will also need to install S...
   $ pcreate –s alchemy myappname
   See setup.py in the root of your application   Installing your app   $ pip install –e .   Installing a forked app ...
   Models for a Pyramid application are stored    in a file called /models/models.py   It creates a class called MyModel...
   Create all of your models in    /models/models.py   Similar to Django
   Routes are defined in __init__.py in the app    rootconfig.add_route(blog, /blog/{id:d+}/{slug})config.add_route(blog_...
   You can map urls to your views using the    views.py file   Use @view_config() decorator for each route@view_config(r...
   The default templating engine is Mako    (http://www.makotemplates.org)   Syntax    % for row in row:        ${makero...
   Addons officially endorsed:    http://docs.pylonsproject.org/en/latest/docs/    pyramid.html#pyramid-add-on-    docume...
$ git clone https://github.com/Pylons/pyramid_blogr.git$ python setup.py develop$ initialize_pyramid_blogr_db development....
Upcoming SlideShare
Loading in...5
×

Intro to Pylons / Pyramid

665

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
665
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
6
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Intro to Pylons / Pyramid"

  1. 1. http://www.pylonsproject.org
  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 (http://bfg.repoze.org) 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- installer.org/en/latest/) $ pip install pyramid You will also need to install SQLAlchemy $ pip install SQLAlchemy
  5. 5.  $ pcreate –s alchemy myappname
  6. 6.  See setup.py in the root of your application Installing your app $ pip install –e . Installing a forked app $ python setup.py
  7. 7.  Models for a Pyramid application are stored in a file called /models/models.py 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): self.name = name self.value = value
  8. 8.  Create all of your models in /models/models.py Similar to Django
  9. 9.  Routes are defined in __init__.py 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 views.py 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 (http://www.makotemplates.org) 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: http://docs.pylonsproject.org/en/latest/docs/ pyramid.html#pyramid-add-on- documentation Add it to your setup.py file Then run $ python setup.py develop May need to pip install the add on first
  13. 13. $ git clone https://github.com/Pylons/pyramid_blogr.git$ python setup.py develop$ initialize_pyramid_blogr_db development.ini$ pserve --reload development.ini
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×