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