Building Data-Driven Web Apps with Pyramid and SQLAlchemy Transcripts
Chapter: Introducing the Pyramid framework
Lecture: Choosing a Python web framework

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now this is obviously a course on Pyramid,
0:02 so we're going to choose Pyramid as our web framework
0:05 for this course, but let's talk through the
0:08 various considerations and some of the trade-offs
0:10 that you make with the web frameworks in Python.
0:14 The best way to think about these frameworks
0:16 is as a spectrum and on one end we have what I
0:20 refer to as the building block frameworks.
0:23 These are things like Django.
0:25 Now what do I mean by building blocks?
0:26 Well, they're really large sections of functionality
0:30 you can just drop in or turn on and off.
0:34 For example, if I want an Excel-like editing
0:38 experience for all of my database,
0:40 all my tables in my database, with Django I can
0:43 just drop that in.
0:44 I can just turn on a thing and, boom,
0:46 you have Excel-like editing or maybe Google spreadsheets,
0:50 more accurate because it's in the web,
0:52 but you have this sort of big things you can drop in.
0:54 You want to a CMS, drop in the CMS.
0:56 You want user management, you drop that in there.
0:58 It comes with a built-in data access layer.
1:02 This is all a positive thing in a sense
1:04 that you get these great pieces of functionality.
1:07 The drawback, and to me just personally,
1:09 this is a pretty big drawback,
1:11 is if you don't like the way those things work,
1:13 if you don't to follow the prescribed way
1:17 of doing things that Django offers you,
1:19 well, too bad.
1:20 Django's going to make it much harder for you
1:23 to be different or to choose what I think of as
1:27 the best of breed building blocks.
1:30 Do you want to use, say MongoDB and Redis
1:34 in this unusual way, you want to create your
1:36 own little management backend, things like that?
1:38 Well, then you still have all the baggage of Django,
1:41 but none of the benefits because it doesn't work that way.
1:44 You're fighting against the system.
1:47 If you would rather work that way,
1:48 what you probably want is a microframework.
1:51 We have one in our framework called Bottle out there,
1:55 super, super lightweight.
1:58 It doesn't do a ton, but it basically says,
2:00 "Here's HTTP request, what do you want to do with that?"
2:03 That's more or less it.
2:05 Probably the most popular microframework would be Flask.
2:08 Flask is very well known and used a lot.
2:11 Flask is a fine framework.
2:13 Probably my second favorite of all of them.
2:15 Flask is good.
2:16 It's a little more common to use Flask
2:20 to create web services than it is
2:22 to create web applications,
2:24 so HTTP services rather than a bunch of pages,
2:28 but of course Flask is used for that as well.
2:32 I'd say Flask offers a little more functionality
2:34 than Bottle and then we have Pyramid,
2:36 which has a little bit more support
2:39 for building full-on web applications
2:41 than say Flask comes with, in my opinion.
2:45 There's some benefits.
2:46 There's some drawbacks.
2:47 Some of the benefits of Pyramid include,
2:49 it has better Python 3 support,
2:51 it has better template support,
2:54 it's faster, couple of other things.
2:56 We'll maybe talk about those.
2:58 It really comes down to the trade-off
3:00 of do you want a microframework
3:02 or do you want one of these big building block
3:03 frameworks like Django, then the difference
3:06 between, say, Flask and Pyramid
3:07 is actually much, much smaller.
3:09 What you learn in one is largely applicable to the other.
3:13 We're going to see that Pyramid being a microframework
3:15 will allow us to use something like SQLAlchemy
3:19 and then if we decide, no actually we'd rather
3:20 switch to MongoDB, no problem.
3:22 That's a super, super minor change
3:25 and everything else will just keep working.
3:27 That's the really nice stuff of a microframework,
3:29 real nice features of a microframework is that
3:32 it let's you pick the various pieces
3:34 and put them together just the way you want,
3:36 not the way the framework wants you to
3:38 or the few choices that framework has made for you.