Building Data-Driven Web Apps with Pyramid and SQLAlchemy Transcripts
Chapter: Welcome to the course
Lecture: Course topics

Login or purchase this course to watch this video and the rest of the course contents.
0:00 In case you haven't already scanned the table of contents to figure out what we're going to cover let's really quickly go through
0:06 some of the topics that we're going to cover in this course. After this introduction section we'll briefly cover what you need to set up your machine
0:13 and the tools and editors you need to follow along. We're going to introduce the Pyramid web framework some of its design principles
0:20 and compare and contrast it with other popular frameworks. We'll create our first site. Here's where we start writing code in this Chapter 4.
0:27 We're going to create our first site and get it up and running in Pyramid. We'll look at the various options for HTML templates
0:34 and then, we'll dig deeper into the Chameleon template language. If you want to use another one, that will be totally fine
0:40 but I make a case for why I think this is the best HTML template language out there. We'll see that mapping URLs to methods
0:47 in our web app is a central part of the MVC framework, the Model-View-Controller framework that is in Pyramid and popular among many
0:54 of the Python web frameworks. So, we'll focus on taking a URL and getting it to run a function and getting some kind of response.
1:01 Once we have some basic pages up and running we'll look at how we make our pages beautiful. We'll bring in Bootstrap. Also talk a little bit about some
1:10 other front-end frameworks if you want to use something other than Bootstrap but we'll look at Bootstrap and how to bring that into our web app.
1:17 At this point, we'll have basic web app functionality happening but it'll all be based on fake, in-memory data.
1:23 Of course, we don't fake, in-memory data. We want live, full-stack web apps. So, we're going to move down a little bit in that stack
1:29 towards the data access layer. We'll talk about SQLAlchemy, how the ORM works we'll define classes that map our data into our database, and, of course
1:38 run queries to get that data back. See, the SQLAlchemy ORM is great for creating the initial database structure
1:44 but if it changes, things are going to go crazy. Right, our database is going to be out of sync
1:50 with our ORM classes and you'll see that's a full-on crash. It's really, really bad. It's kind of hard to maintain the stuff.
1:55 Well, Alembic, a database migration framework that's peered with SQLAlchemy will come to the rescue. We can point Alembic at our SQLAlchemy classes
2:04 and our database, and go, alright. We changed these. Make the database scripts that are needed to do that change, to apply those changes automatically.
2:12 Just make that for us and then we can apply that to like say, staging or production as we roll out new versions. It's going to be great.
2:19 Once we have our database working we'll want to accept user input. Probably save it to the database, as well. So, we'll talk about HTML forms
2:25 letting users create accounts register, enter data, that sort of thing. If you're accepting data, you had better be validating it, right?
2:33 The internet is a harsh place and lots of people try to send invalid data either by mistake or maliciously.
2:39 We're going to talk about some really awesome design patterns called view models for server-side validation and data exchange
2:45 and then, we'll also talk about leveraging some HTML5 features so we don't have to write any JavaScript for client-side validation.
2:52 Testing web apps can be tricky because web applications depend upon things like databases, and other services and the web framework, itself, right?
3:01 Like the request-response model, all that. So, we'll see that Pyramid provides special infrastructure to make it testable
3:08 so that we can test our web application more easily without actually creating the servers and doing heavy weight stuff like that.
3:15 Once our app's built, tested, everything's working, it's time to ship it, right? Put it online, so we're going to take our web app and deploy it
3:23 on a brand new Linux server out on the internet and we'll have our web app running and live. You'll see everything you need to do
3:30 to take a bare Ubuntu image, and get it up and running to be our web and database server. Finally, we're going to take a look back at
3:39 how we built our application how we've structured it so that we have a lot of flexibility using various design patterns for accessing data
3:48 and validating data, and so on. And as an exercise, we're going to convert from a relational database to a MongoDB database.
3:56 That's interesting, if you want to know about MongoDB, you'll see how to do that but it's also interesting just to show
4:01 how flexible these design patterns are because we're going to make this conversion by just changing a few handful of files
4:08 even though there'll be many, many aspects of our site. We'll have that really isolated and focused so it's super easy to do whatever
4:15 we want with our data access. If you wanted to, say, convert it to calling web services and some kind of micro service architecture
4:22 you'd see the techniques we're using here for MongoDB would equally apply to that exact same transformation. This is what we're going to cover.
4:30 I hope you find it super interesting. It's a real world version of what you need to build and ship web applications.
4:36 This is almost everything you need to know to go from I know a little bit of Python and HTML to running these full-stack web apps
4:43 that are things like the training site or YouTube, or stuff like that. I hope you're excited to learn it. I'm definitely excited to share it with you.

Talk Python's Mastodon Michael Kennedy's Mastodon