
Intro to the Python Framework Pyramid - saurabh
http://www.sixfeetup.com/blog/intro-to-the-python-framework-pyramid-and-a-sample-app
======
lifeisstillgood
I am "mentoring" a python dev on HN and far and away the most important thing
I think he can do is _not_ learn a framework till the underlying WSGI process
is firmly embedded in his brain

I used to think getting a site up and running in ten minutes meant something
bu I tend to believe it is usually teaching bad habits or allowin untrue
mental models to develop

Dammit we need developer education. !:-)

~~~
chrismorgan
Why do you feel knowledge of WSGI is critical? (I can think of a few reasons
why it's a very good idea to know what's going on roughly, but I wouldn't put
it as strongly as you have, and I'm curious to know your reasons.)

~~~
lifeisstillgood
It's kind of that frameworks are still the silos wsgi was supposed to solve.
Look at flask - it started off as little more than the code examples in PEP333
! Then people went great ! And it was great. Except that it had let's say
OpenId added to the framework.

Now in my opinion the right place to do authorisation is earlier in the wsgi
chain - using say repoze.who.

But now someone coming along sees the framework can do this and instead of
learning how to chain wsgi apps they just take Armins excellent skeleton code
and hey presto Flask starts to bloat.

This is not a complaint about Flask per se (I think Armin is doing a Stirling
job promoting a smaller way) but it is about a chain that was supposed to mean
we could pick best of breed middleware and yet we are still in which framework
is best debates

It should never be how to learn pyramid / flask / django in one day but should
be how to deploy a micro-service and chain it in front of authentication
middleware and hey presto a working API. Stuff your templates.

~~~
irahul
> it started off as little more than the code examples in PEP333 !

Flask had less than 1000 lines when it begun, but werkzeug is much bigger than
that.

> Except that it had let's say OpenId added to the framework.

Is that supposed to be a hypothetical example? Because Flask framework doesn't
have openid added to it. Flask extensions for it exist, just the way it
should. The users can write whatever extensions they want - that shouldn't
concern framework developer or other users.

> Now in my opinion the right place to do authorisation is earlier in the wsgi
> chain - using say repoze.who.

I don't know what repoze is. But if you want to insert a wsgi middleware, you
can easily do it in flask.

> But now someone coming along sees the framework can do this

The framework doesn't do auth.

> they just take Armins excellent skeleton code

I don't know which snippet you are talking about, but I believe that's about
how to use Flask-OpenId extension.

> but it is about a chain that was supposed to mean we could pick best of
> breed middleware and yet we are still in which framework is best debates

Flask-openid is a wsgi chain. Flask app object is a wsgi object, and openid
extension wraps it. Also, my concern would be ease of integration and
extensiblity, not what level it works at.

------
boothead
Flexibility and scalability - those are the two takeaways from this.

I've always found django (for example I'm not specifically down on django) to
be quick to get up and running but to lead you gently down a path that ends
with a very high brick wall.

Pyramid on the other hand is so flexible that pretty much any part of the
framework can be swapped out for something else and you can abstract the
important parts of your app into a mini-framework for yourself. An example of
this: The code I have <100 lines of code in a file called rest_traversal.py
that maps SQLAlchemy mapped tables to urls like:

/db/Model -> all instances of Model /db/Model/1 -> model 1
/db/Model/1/relationship -> all members of model 1's relationship

I'm currently using Pyramid to build the real time front end to an algorithmic
trading system and it's been the perfect balance for me.

~~~
ineedtosleep
Not disagreeing with you here, but is it the case that (most) people build on
Django expecting it to scale very well later on? I've not built any Django
apps that have seen the light of day, but I've always had the impression that
once you have something up and running and are now, hopefully, getting some
revenue that transitioning to something more scalable would be much less
painful. Reason being, the vision was clarified under Django through a number
of (hopefully) quick tweaks here and there.

Or does your experience say otherwise? If one were to build something that
would need to be immediately scalable, don't even think of Django and head
towards something like Pyramid and Flask?

~~~
matthiaswh
No! Django scales well and scalability is not a very good reason to switch
away from Django. Plenty of high volume sites are powered by it, most famously
Disqus.

~~~
garindra
Pinterest is built on Django too.

------
SixFeetUp
Hey guys, thanks for checking out our post on Pyramid. We really do like the
flexibility it offers over Django. We are also coming out with a follow up
blog post from the IndyPy web shootout next week that will also have the
videos of the 4 presentations on Pyramid, Bottle, Django, and Flask. I'll link
to it on HN then.

Also if you are interested, make sure you check out the Pyramid app on github
(linked from the article, [http://www.sixfeetup.com/blog/intro-to-the-python-
framework-...](http://www.sixfeetup.com/blog/intro-to-the-python-framework-
pyramid-and-a-sample-app)) to see step by step how we built the todo app.

At Six Feet Up we love Python and spend most of our time building enterprise &
higher ed CMS and intranet solutions along with Pyramid or Sencha apps. We are
also really interested in understanding how others are using Python in
startups and the enterprise.

------
sghill
If you're interested specifically in building web services, I've had some good
trials with Mozilla's cornice[1][2], which is built on top of Pyramid.

[1] <http://cornice.readthedocs.org/en/latest/quickstart.html>

[2] <https://github.com/mozilla-services/cornice>

------
Stratoscope
FTA:

> Pyramid is based on Zope, Pylons, and Django.

It is? Explain.

~~~
tshepang
I questioned this sentence too, but the meaning is explained in the article,
if you read a bit further.

