Python for Entrepreneurs Transcripts
Chapter: Build web apps with Pyramid: Applied web development
Lecture: Intro to applied web development

Login or purchase this course to watch this video and the rest of the course contents.
0:02 Are you excited? I know that I am. We have reached the chapter where we dig in and really build our web application.
0:11 We are going to focus on all the stuff you need to build a data-driven web app now that you have all the foundational stuff in place.
0:18 We are going to start with something called handlers. Pyramid handlers. Now, these are not super well known features of Pyramid
0:26 or extension of Pyramid really is the way to think of it, it's a separate PyPi package. But, they allow us to do simpler routing and more importantly,
0:36 they provide what I would consider universal access to core features. If for some reason we want to be able to access the user in a certain way,
0:46 or a particular cookie, like an authentication cookie, various places where we are processing the request,
0:52 remember in a real web app you have like a hundred, two hundred methods that are actually handling these requests
0:57 talking to the database and doing things, and the right level of separation is really important. Handlers facilitate that,
1:03 in a really interesting and powerful way, and they are quite easy to use, I think you'll find them of nice addition.
1:09 We are also going to look more carefully at the Chameleon templates,
1:12 so we haven't done a whole lot with these templates other than sort of poke at them and say that they exist, but we are really going to look at them
1:20 and use them to build a website. We are going to go and take real data and pass it onto the templates and do interesting things with it.
1:27 We are also going to stop making copies of our website design what we've done so far is we sort of copied pieces around
1:34 and poked it at saying "look we'll address this later", we are now going to address this concept of a shared layout,
1:40 we are going to do this through a mechanism inside of Chameleon, called Macros and you'll see that we have a single layout page that defines
1:48 basically a hole where the customized content goes for each particular view, and then we are going to put all that stuff,
1:54 all the CSS all those sort of wrapper bits of the HTML in one page, one template and share it across the whole thing.
2:01 So that means if we want to add a new page, it's super easy, we just fill in that hole,
2:05 if, more importantly, if we want to change the look and feel for our site, we just do that in one place and every page in our site
2:12 automatically adapts to that common look and feel. We are not going to do read-only data anymore,
2:18 we are now going to accept input from users, let them edit things, this can be as simple as letting them log in
2:24 or letting them register to create an account, but it could get more advanced with some kind of backend admin section that we might build,
2:32 certainly to do things like input our albums into our web page, we are going to need some kind of admin backend.
2:40 While passing pure dictionaries around is what is required by the template
2:44 and it's the way Pyramid works, it doesn't mean that that's what we should be doing, we are going to introduce this concept of a view model
2:52 which is a richer, more intelligent class basically that is tied to the template
2:58 that it's being displayed in, has the validation rules and some of the data access rules that we might need in this separate layer.
3:06 So, when we do this, the action methods, the ones that actually process the request, their job will be much simpler and some of that validation
3:15 and the complexities of whatever problem we are trying to solve will be moved over into this view model.
3:20 This will make it easier to maintain and validate our code, but it will also make it easier to test our code
3:26 because we can work with the validation in these view models, not just poking at fake web requests.
3:32 Speaking of validation, we'll see that the view models are an important player in the server-side validation, which we are going to need
3:41 and we are also going to talk about adding client-side validation, so that most of the time we don't even have to go back to the server,
3:47 users get immediate feedback saying what they need to do to properly fill out the form. Alright, so that's what's on deck for the chapter,
3:54 I think you are really going to learn a lot after we get through these topics.

Talk Python's Mastodon Michael Kennedy's Mastodon