Building Data-Driven Web Apps with Pyramid and SQLAlchemy Transcripts
Chapter: User input and HTML forms
Lecture: Navigation items based on user sessions
0:00 We've seen over here that our login
0:02 and register still appear even though
0:04 we are technically logged in.
0:08 If I go there, we are technically logged in.
0:11 So let's fix that.
0:12 This is part of the shared layout template up here.
0:18 We'll go down to this section here.
0:21 Put a little separation for these.
0:24 We'll have some kind of condition here.
0:26 tal:condition, not userid.
0:31 So we can communicate back to this template
0:33 what the userid was.
0:36 It turns out that this gets to be
0:37 challenging to always do this in the right place.
0:40 But let's do it for a minute and then we'll fix it.
0:45 This one, of course, we're going to
0:46 change the account and logout.
0:55 Log out doesn't exist yet, but easy enough.
0:57 So this might seem like a great idea
0:59 but if we pull it up, not so much.
1:02 So it turns out that if we do it this way
1:05 every single part of our site
1:09 is going to have to always pass the userid.
1:12 We're going to do that now and we're going to fix it in the next chapter.
1:14 Let's go over, we need the HomeController.
1:20 Here we have to have userid
1:26 and pass the request.
1:28 I'm going to show you a better way.
1:29 But for now, this is what we're going to do.
1:33 We don't have it everywhere.
1:34 It's going to fail. But let's just see that it works on the homepage.
1:37 Boom, it's back and look at this, account and logout
1:39 because we're logged in that's so awesome.
1:40 'course if I click on account, it fails.
1:43 Let's go work on that one. That one's easy.
1:52 So I'm just going to put these on the rest, it's all the same.
1:56 Alright, look everything is back.
1:57 It looks like its all working.
1:59 We can even go to the packages.
2:00 That was super annoying
2:02 but it is nice that it's driving this.
2:04 We're going to fix that, like I said.
2:05 But here we have our site up and working
2:08 with user sessions and cookies.
2:09 Let's do one more thing.
2:10 I'll fully quit Firefox and come back
2:12 just to see we're still logged in.
2:17 Logged in, of course in a private window, not so much.
2:21 Log in and register versus account and log out, awesome.