Building Data-Driven Web Apps with Pyramid and SQLAlchemy Transcripts
Chapter: Routing and URLs
Lecture: Concept: Using the routes

Login or purchase this course to watch this video and the rest of the course contents.
0:00 All right, let's real quickly
0:01 review using the routes
0:03 creating and using the routes.
0:04 So, we start out going to config
0:06 this is in
0:08 Go here and we say add route
0:09 and we give the route a name
0:11 and a URL. And that URL may or may not contain variables.
0:16 We saw in the release example
0:18 for an individual release
0:19 there's actually two variables interspersed
0:21 into the URL there that we could grab out
0:23 which is pretty awesome.
0:25 And then we're going to create a view method
0:28 and apply the route name to be the name passed there.
0:32 And then things will be better for you
0:34 just keeping track
0:35 if you do some organizations.
0:37 So we'll use the help template in the home folder.
0:40 The name of the function is help and so on.
0:42 But there's no reason they have to correspond
0:44 other than it helps you link these things together
0:47 because there's no other real way to know
0:50 what links where.
0:51 To get the value passed in the URL.
0:53 So if somebody said /help/installing
0:58 We're going to go to the request.
0:59 We'll go to the matchdict
1:00 then we say get topic and it's going to give us installing.
1:03 And what I've done here is I've passed overview
1:05 as a second parameter there
1:06 so for some reason
1:08 no topic is passed or it's not found
1:10 we're going to pull back some kind of default help
1:12 we can show them
1:13 instead of showing a 404
1:14 like here's an overview of the thing.
1:16 You asked for help that didn't exist.
1:18 So you're going to get just an overview.
1:20 And that's really is all there is to it.