[Grok-dev] a grok.getApplication() implementation
kevin at bud.ca
Thu Nov 26 20:22:02 EST 2009
The grok.getApplication() has been discussed/proposed a few times in
the past, e.g.
I'd really like this function available in Grok, so I put together an
implementation, and some tests for it, available on a branch:
The implementation, in grok.utils, just looks like this:
"""Get the application."""
site = grok.getSite()
# another sub-site is within the application, walk up
# the tree until we get to the application
parent = site.__parent__
while not grok.interfaces.IApplication.providedBy(parent):
parent = parent.__parent__
Not sure if there is a better way to do this?
The tests are in src/grok/ftests/application/, they could maybe be
improved as my Site() zen is also not super great. Although this
feature is relatively simple, so perhaps it's good enough to be merged
(docs need to be updated to, I can do this post-merge)
More information about the Grok-dev