Adding a CMS to Your Pyramid Web App Transcripts
Chapter: Redirects and the admin section
Lecture: Creating the redirect in our simple DB
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
But let's go over here and put this CMS service. That create redirect.
0:08
So we've gotten a post back, We validate the data, we're gonna do the thing, save it, and then do the redirect.
0:14
So this will be a `vm.name`. `vm.short_url`, `vm.url` Yeah, I think that'll do it. Create that function. `name, short_url, url`. Great.
0:24
Well, if we go over to this thing, we're gonna have a database for real in a minute. We're just going to stick something that looks like this in there.
0:30
So let's go back. I'll have a data, woops. I say data equals this. So this thing is the short url, the ID.
0:43
Let's just put by for a minute. We'll figure that out a second. This is gonna be the url we'll be also the short url, and this will be the name.
0:52
And in here, we're just gonna go to `fake_data.redirects`. Our port url is going to be... Actually, we were had it. Let's just do it like this.
1:05
It's goign to be data. There we go. That's what we want. And that will put it just while it's running into our fake database.
1:12
And then, you know, when we get to a real database a little bit down the road, this will be working great.
1:16
So come over here. Refresh it. Add in a redirect. Now we gotta do it again. Talk Python. Talk CMS. Talk Python.
1:24
Okay, this should work. When it saves it back to the database, just temporarily in memory, it should show up in our list. Let's give it a try.
1:32
Oh, yeah, There it is. Check it out. Courses, bytes, and this, and check out the url. talkpython.fm. There we go. Let's add one more. Just for fun.
1:41
Google, g, google.com. All right, so if we type Go up here and open up a new tab type just `/g``. Look where we are. Beautiful, very, very cool.
1:55
So it looks like our ability toe create these new redirects is great. It's working just fine.
2:01
The only the last thing to do is edit it, but truthfully, we're basically done with that.
2:05
We just need a very, very small change to keep track of the original data. And we're done with this whole redirect admin section.