Skip to content

Mapping code to a url

xiongchiamiov edited this page Sep 17, 2014 · 2 revisions

While trying to figure out what exactly some bit of code you're looking at does, or trying to test a bugfix, it's helpful to be able to visit pages that actually use the code in question.

First, let's take a look at how urls get mapped to controllers, as that will make the reverse process much easier to understand.

From a URL to the code that serves it

The first place to start is routing.py. As the name suggests, this file contains the primary routing logic to decide what code should be called for each request. While Pylons has some documentation on the module, it's not terribly helpful; you'll probably find the routing section of the tutorial easier to understand.

From there, you should be pretty much set - match the controller parameter to a file in the controllers directory, and action to a method in there, and it's on to normal code execution and tracing.

From code to urls

The backward process is a bit more difficult, since there is no trivial way to find mappings from definitions back to callsites. sgrep, git grep, grep, and ack are your friends, and hopefully you'll eventually work your way back to routing.py.

Clone this wiki locally