[Grok-dev] Re: Getting the application in views and viewlets
gns24 at mythic-beasts.com
Mon Jun 16 19:59:57 EDT 2008
On 17 Jun 2008, at 05:49, Jan-Wijbrand Kolman wrote:
> Graham Stratton wrote:
>> I seem to quite often need to get the application, or the
>> application url, in views and viewlets.
>> Views have the application_url method, but viewlets don't. I'd be
>> tempted to suggest that both views and viewlets grow an
>> `application` property.
>> Do other people find this a common requirement, or is there
>> something wrong with the way I'm developing applications?
> I think your issues are addressed by my post just now  about the
> jw-viewlet-fix branch and https://bugs.launchpad.net/grok/+bug/226555.
> As a result of the fix for that bug, there is actually no need
> anymore for having an (application_)url() method on the viewlets.
But how can I get the application itself? Or is accessing attributes
of the application directly in the templates considered a bad idea?
My suggestion wasn't as much about viewlets as about making the
application object available in templates. It's currently quite tricky
to get the application anywhere, and I'm still not sure what's
considered the correct way to do it, whether by utility lookup or
traversing __parent__ until we find the Application.
More information about the Grok-dev