Python for Entrepreneurs Transcripts
Chapter: Build web apps with Pyramid: Applied web development
Lecture: Concept: Base controllers

Login or purchase this course to watch this video and the rest of the course contents.
0:02 As you've seen, creating a base controller, some kind of class that all of our controllers derive from,
0:09 allows us to centralize a lot of shared functionality. First of all, we no longer need to define a dunder init
0:16 that grabs the request, which is a requirement for all the controllers, it also lets us set things like that cache busting utility,
0:23 making that available to all the views and here you can see we are setting a page title that means we can go into our templates
0:31 and say I'd like to set the title to view.page_title. And things it derive from the controller base, if they want to change the title,
0:38 they can just set the title to something else before it gets rendered. But this way every template and as you'll see, the shared master template later,
0:46 will be able to rely on this field being there. We also can set properties to say "is this a get request or a post request?" and simplify that,
0:54 here you can see we even gave a set_title function that will let us define a common ending for the title of our web app
1:02 that let us specify some little prefix like your account-my web app, things like that,


Talk Python's Mastodon Michael Kennedy's Mastodon