41 messages in com.googlegroups.pylons-discussRe: Controller name
FromSent OnAttachments
Mikeroz22 May 2008 07:37 
Mike Orr22 May 2008 09:31 
Mel Raab22 May 2008 10:07 
Duong Vu22 May 2008 10:50 
Kyle Crawford22 May 2008 12:44 
Shannon -jj Behrens22 May 2008 15:07 
Mike Orr22 May 2008 15:20 
Garland, Ken R22 May 2008 16:20 
Noah Gift22 May 2008 17:57 
Raoul Snyman22 May 2008 23:46 
Mike Orr23 May 2008 00:42 
Christoph Haas23 May 2008 01:37 
Shannon -jj Behrens23 May 2008 01:57 
Raoul Snyman23 May 2008 02:06 
wongobongo23 May 2008 02:35 
Ross Vandegrift23 May 2008 07:15 
Cliff Wells23 May 2008 09:45 
Mike Orr23 May 2008 11:51 
Noah Gift23 May 2008 18:53 
Antonio Beamud Montero28 May 2008 02:45 
Christoph Haas28 May 2008 03:50 
Antonio Beamud Montero28 May 2008 04:10 
Christoph Haas28 May 2008 04:19 
Antonio Beamud Montero28 May 2008 05:40 
Mike Orr28 May 2008 08:30 
Jonathan Vanasco28 May 2008 10:13 
jerry28 May 2008 13:24 
Mike Orr28 May 2008 14:58 
Alberto Valverde29 May 2008 05:07 
Jonathan Vanasco29 May 2008 21:33 
Shannon -jj Behrens30 May 2008 09:17 
Alberto Valverde30 May 2008 11:40 
Noah Gift01 Jun 2008 15:15 
iain duncan01 Jun 2008 20:30 
Mateusz Haligowski01 Jun 2008 20:44 
Mike Orr02 Jun 2008 11:34 
Thomas G. Willis05 Jun 2008 07:17 
Kevin G. Baker05 Jun 2008 08:51 
Mike Orr05 Jun 2008 12:34 
Ian Bicking05 Jun 2008 13:14 
Florent Aide05 Jun 2008 13:32 
Subject:Re: Controller name
From:Mike Orr (slug@gmail.com)
Date:05/28/2008 02:58:13 PM
List:com.googlegroups.pylons-discuss

Hmm, it looks like it does it only for variables listed in the action's arguments. (In pylons.controllers.core.WSGIController._inspect_call()). I thought it did it for all routing args. So you could define your action as:

def.__before__(self, controller): # Sets c.controller c.controller = controller # Or do it again to be explicit.

--Mike

On Wed, May 28, 2008 at 1:24 PM, jerry <jerr@gmail.com> wrote:

Hi Mike,

c.controller auto-assignment doesn't seem to be implemented in Routes1.8 --

(Pdb) list 22 def index(self): 23 import pdb; pdb.set_trace() 24 -> #c.url_for_action = 'index' (Pdb) !c.controller 16:15:01,505 DEBUG [pylons.util] No attribute called controller found on c object, returning empty string ''

On May 28, 11:30 am, "Mike Orr" <slug@gmail.com> wrote:

On Wed, May 28, 2008 at 3:50 AM, Christoph Haas <em.@christoph-haas.de> wrote:

Hi, Antonia...

first of all: please don't hijack threads. Start a new thread if you want to post to this list. Don't just reply to a random posting.

On Mittwoch, 28. Mai 2008, Antonio Beamud Montero wrote:

How I can get the controller name in the actual template context. For example, a site.mako template used by several controllers, I want to show the controller name with something like this:

${c.name}

It's possible or I must define a property for every controller with it's name?

The routes dictionary contains the information you are after:

request.environ['pylons.routes_dict']

You cann add a "def __before__(self)" in the lib/base.py and fill a template variable with it to be used in the templates:

c.routes = request.environ['pylons.routes_dict']

That would allows you to access the current controller's name in the template as:

${c.routes['controller']}

Actually, it's easier than that: ${c.controller}

Routing variables are automatically added to 'c'.