views:

16

answers:

1

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

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