Building Data-Driven Web Apps with Pyramid and SQLAlchemy Transcripts
Chapter: User input and HTML forms
Lecture: Navigation items based on user sessions

Login or purchase this course to watch this video and the rest of the course contents.
0:00 We've seen over here that our login and register still appear even though we are technically logged in. If I go there, we are technically logged in.
0:12 So let's fix that. This is part of the shared layout template up here. We'll go down to this section here. Put a little separation for these.
0:25 We'll have some kind of condition here. tal:condition, not userid. So we can communicate back to this template what the userid was.
0:37 It turns out that this gets to be challenging to always do this in the right place. But let's do it for a minute and then we'll fix it.
0:46 This one, of course, we're going to change the account and logout. Log out doesn't exist yet, but easy enough. So this might seem like a great idea
1:00 but if we pull it up, not so much. So it turns out that if we do it this way every single part of our site is going to have to always pass the userid.
1:13 We're going to do that now and we're going to fix it in the next chapter. Let's go over, we need the HomeController. Here we have to have userid
1:27 and pass the request. I'm going to show you a better way. But for now, this is what we're going to do. We don't have it everywhere.
1:35 It's going to fail. But let's just see that it works on the homepage. Boom, it's back and look at this, account and logout
1:40 because we're logged in that's so awesome. 'course if I click on account, it fails. Let's go work on that one. That one's easy.
1:53 So I'm just going to put these on the rest, it's all the same. Alright, look everything is back. It looks like its all working.
2:00 We can even go to the packages. That was super annoying but it is nice that it's driving this. We're going to fix that, like I said.
2:06 But here we have our site up and working with user sessions and cookies. Let's do one more thing. I'll fully quit Firefox and come back
2:13 just to see we're still logged in. Logged in, of course in a private window, not so much. Log in and register versus account and log out, awesome.

Talk Python's Mastodon Michael Kennedy's Mastodon