7 messages in com.googlegroups.pylons-discussRe: Accessing controller name and act...| From | Sent On | Attachments |
|---|---|---|
| Matt Feifarek | 24 Aug 2006 23:20 | |
| yi huang | 25 Aug 2006 00:38 | |
| Matt Feifarek | 25 Aug 2006 00:48 | |
| Ben Bangert | 25 Aug 2006 08:15 | |
| Matt Feifarek | 25 Aug 2006 10:31 | |
| Ian Bicking | 25 Aug 2006 10:37 | |
| Matt Feifarek | 25 Aug 2006 15:16 |
| Subject: | Re: Accessing controller name and action name from myghty![]() |
|---|---|
| From: | Ben Bangert (be...@groovie.org) |
| Date: | 08/25/2006 08:15:05 AM |
| List: | com.googlegroups.pylons-discuss |
On Aug 25, 2006, at 12:48 AM, Matt Feifarek wrote:
On 8/25/06, yi huang <yi.c...@gmail.com> wrote: Maybe you can set c.controller_name in yourproject.lib.base.BaseController
Thanks.
I thought of that, and I can certainly do that, but I thought that this might be a good opportunity to learn the "right way" to get that info, and where that info is.
When Pylons parses the URL with Routes, it puts the routing dictionary into an environ variable 'pylons.routes_dict', so you can find the controller in your template/controller code as request.environ['pylons.routes_dict']['controller'] and request.environ['pylons.routes_dict']['action'].
The controller uses these variables directly from that source to dispatch to your action as well:
http://pylonshq.com/docs/0.9.1/pylons/controllers.py.html? f=111&l=145#111
Line 121 in particular is where it pulls out the information and then calls your action.
HTH, Ben
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to pylo...@googlegroups.com
To unsubscribe from this group, send email to
pylo...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/pylons-discuss
-~----------~----~----~----~------~----~------~--~---




