Building Data-Driven Web Apps with Pyramid and SQLAlchemy Transcripts
Chapter: Routing and URLs
Lecture: Concept: Using the routes
0:00 All right, let's real quickly review using the routes creating and using the routes. So, we start out going to config this is in __init__.py
0:09 Go here and we say add route and we give the route a name and a URL. And that URL may or may not contain variables. We saw in the release example
0:19 for an individual release there's actually two variables interspersed into the URL there that we could grab out which is pretty awesome.
0:26 And then we're going to create a view method and apply the route name to be the name passed there. And then things will be better for you
0:35 just keeping track if you do some organizations. So we'll use the help template in the home folder. The name of the function is help and so on.
0:43 But there's no reason they have to correspond other than it helps you link these things together because there's no other real way to know
0:51 what links where. To get the value passed in the URL. So if somebody said /help/installing We're going to go to the request. We'll go to the matchdict
1:01 then we say get topic and it's going to give us installing. And what I've done here is I've passed overview as a second parameter there
1:07 so for some reason no topic is passed or it's not found we're going to pull back some kind of default help we can show them instead of showing a 404
1:15 like here's an overview of the thing. You asked for help that didn't exist. So you're going to get just an overview.
1:21 And that's really is all there is to it.