[Grok-dev] Re: Getting the application in views and viewlets

Leonardo Rochael Almeida leorochael at gmail.com
Thu Jun 19 12:09:03 EDT 2008


Hi,

On Thu, Jun 19, 2008 at 12:56, Martijn Faassen <faassen at startifact.com> wrote:
> [...]
>
> I think we might want to implement grok.getApplication().
>
> What the right implementation should be I'm not sure about. You could do it
> by traversing __parent__ until you find the Application.
>
> You could also do it by looking up getSite, checking whether it's the
> application, and then if not walk up the __parent__ chain from the site.
> This would be slightly faster in many common cases.
>
> Alternatively you could register the application as a local utility in the
> application itself upon creation. This would allow the local utility lookup
> machinery to do everything for you. The drawback is that it'd need a content
> upgrade for existing applications to become equipped with this existing
> application.
>
> Graham, patches are welcome. I think the getSite() approach might be the
> best approach right now.

Or maybe a fallback approach? Register the application as a local
utility and if that doesn't work, log a deprecation warning and look
it up through getSite() and __parent__.

Cheers, Leo


More information about the Grok-dev mailing list