开发者

How to know the 'controller' and 'action' from the request url?

I want to log the controller and action when a request comes, so I write a __before__ in the base controller:

开发者_如何转开发 class BaseController:
     __before__(self):
          controller = get_controller(request)
          action = get_action(request)
          logger.log('%s - %s'%(controller, action))

But I don't know how to get the controller and action just from the request


 params = request.environ['pylons.routes_dict']
 print dir(params)
 #-> {'action':u'action', 'controller':u'controller'}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜