Adding a CMS to Your Pyramid Web App Transcripts
Chapter: Redirects and the admin section
Lecture: Pulling data from the form

Login or purchase this course to watch this video and the rest of the course contents.
0:00 says the last thing we need to do is somehow have this view model, validate and grab that data. So here's what we're gonna do.
0:06 We have a method called restore from How about this process form poster,
0:12 Something like that which doesn't exist and will say if vm not error return VM not to dict. So if this were to set the error here,
0:21 we're gonna return that and show it. So let's just do that real quick. And he would just say self done. Error equals test error that rerun it.
0:32 Now if I hit Refresh, it's going to show. First of all, notice all of the data went away. How frustrating. Fix that in a sec.
0:40 It Reese tend here who test error. Okay, that's cool. We got our test error back. Didn't let us go by The other thing that we need to dio it's We need
0:49 to get all of this data back. So in this view model that has a sinkhole to request dicked, it was really long to keep writing that.
0:58 So I'm gonna go over here and say d equals that so we can say, Do you not get short or ill?
1:03 and was gonna do that for the rest of them are going to get the u R l. And here we're going to say,
1:10 if not self does short girl just add a little validation, give you a sense it might need more, but we'll get going here. You must specify a short euro.
1:24 Another one that might happens would say, If CMS service don't get redirect from self dot You're all this would be the case
1:34 where you try to create a new one for one that already exists in the air would be already exists or something like that. We contest that in a minute.
1:43 So this is going to do to nice things is going to allow us over here Notice these Never refill themselves. They're gonna start doing that now.
1:52 And let me just set on more time, self dot There equals hold tight just to make it stop for a second and still
2:01 have these air conditions. So I try to submit the page again and it says hold tight. But look,
2:05 now the data is coming along so I can change this to you. Talk to and the data goes back and forth,
2:13 which is super helpful because we don't have to keep typing that. But let's get this little fake air handling out of the way.
2:19 And we started. And that would work. Except for it would create the redirect. And then the last thing to do is to actually do the get post redirect.
2:32 Not the one Lucretia, but just take him somewhere. So we're gonna say return http found and where we want them to go slash admin
2:41 slash redirects. So we just created a new redirect. Let's show them a list of existing ones. All right, let's do that. So this put bites for a second.
2:50 So that'll do our validation. Redirect with bites already exists, but not talk. No, no. So talk should work. If we hit this,
2:57 it should take us to our list. Does perfect, however, didn't create it? That's the final final thing, right?


Talk Python's Mastodon Michael Kennedy's Mastodon