开发者

New to Pylons and Trying to Understand Routes

开发者 https://www.devze.com 2023-04-01 11:15 出处:网络
I am new to pylon and trying to understand this piece of code: map.connect(\':controller/:action/:id\')

I am new to pylon and trying to understand this piece of code:

map.connect(':controller/:action/:id')

An开发者_运维百科y help would be much appreciated, thanks in advance!


That's a generic route that tells pylons approximately to "Split up an incoming request url into three parts, try to find a controller classed named after the first path item, with a method named after the second. If that exists call it with the third path item as argument." These kinds of paths are common for web API's that expose database backed objects, where the 'controller' is the name of the model class, the 'action' is some method on that model, and 'id' would be the primary key of the database entity to be affected.

The routes logic in pylons exists as a python package of its own, with some in-depth documentation on how it can be used.

0

精彩评论

暂无评论...
验证码 换一张
取 消