On Jan 2, 2011, at 8:19 AM, villas wrote:
> 
> Hi Jonathan
> If the framework had such a variable I would use it. But it's a tiny
> issue so please don't let me further distract you from the other
> enhancements you are planning :-)

It'll be (almost) trivial to add it. I'll put it on my todo list.

> Thanks.
> D
> 
> On Jan 2, 3:58 pm, Jonathan Lundell <[email protected]> wrote:
>> On Jan 2, 2011, at 5:54 AM, villas wrote:
>> 
>> 
>> 
>>> Well, say I make a plugin which I want to link back to a function in
>>> my default_controller. I would not wish to to make my link like this
>>> URL('default','func'), but like this URL(default_controller,'func').
>>> See what I mean?
>> 
>> Sort of. The problem is that you're not guaranteed of having a 
>> default_controller, unless someone has appropriately configured and 
>> installed an app-specific router for that application (or made it the 
>> default application in the base router).
>> 
>> I can provide an API (something like gluon.rewrite.get_router(appname)) that 
>> would return the effective router (dict, or actually Storage) for a given 
>> application, but I can't guarantee that any particular item will be defined 
>> in it (or even that a router exists).
>> 
>> You could then do something like this:
>> 
>>         from gluon.rewrite import get_router as router
>>         ...
>>         URL(router(request.application).default_controller or 'default', 
>> 'func')
>> 
>> or define your own global in a model file:
>> 
>>         from gluon.rewrite import get_router as router
>>         ...
>>         my_default_controller = 
>> router(request.application).default_controller or 'default'
>> 
>> Would that work?
>> 
>> 
>> 
>>> On Jan 2, 2:09 am, Jonathan Lundell <[email protected]> wrote:
>>>> On Jan 1, 2011, at 5:46 PM, villas wrote:
>> 
>>>>> The 'default_controller' variable in routes.py doesn't seem to be
>>>>> available in the rest of the app.
>>>>> From where may I access that information?
>>>>> Or, do I have to set that variable again in as an app setting
>>>>> somewhere (not very DRY!).
>> 
>>>> I'm not sure what you're asking. Why would you want to access it?
>> 
>> 


Reply via email to