Adding a CMS to Your Pyramid Web App Transcripts
Chapter: Routing for the CMS
Lecture: Concept: Adding the cms route

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's quickly review the routing needed to add this custom CMS method, which is going to be the entry point to handling all the CMS requests.
0:09 Now we saw that we can go config that around to control the way your URLs are mapped to different parts of our web application.
0:17 We give it a name, and then we give it some kind of pattern to match. And the trick here for the CMS one in pyramid is say star subpath.
0:24 That means match everything Just give me any URL that could possibly be typed into the website and I'm gonna handle it
0:32 Now, obviously, if this goes first, here's the only page, the only request, only method that's gonna run on your site.
0:38 So this one needs to go at the end. But it's kind of the one that catches the ones that are missed by all the other
0:44 more structured parts of your website We're gonna map that over to a method with a view config.
0:49 When I say the route name is CMS, which we put at the top. We're gonna give it away to render it itself to a page.
0:55 We'll talk more about that later and we've got some method This one called a page.
0:59 and here we get our subpath as a list of the pieces separated by the slash.
1:05 But what we're storing the database is just a string that is the entire girl So that's what this little joint statement does.
1:11 Then, we go to our CMS service, get us the page and hand it back to that template to show it to the user.
1:16 And this is the basics of how do we get started handling requests for this arbitrary URLs on our website.
1:24 And that's the key to making this CMS thing work.
1:28 And just remember this route the top piece must go the very end of all of your route definitions because
1:33 it matches everything and the matching happens from top to bottom, So this had better be at the bottom


Talk Python's Mastodon Michael Kennedy's Mastodon