def get_root_folder(): """Get the Root Folder of a Zope instance.""" site = grok.getSite() if IApplication.providedBy(site): return site.__parent__ else: # another sub-site is within the application, so # walk up the tree until we get to the root folder parent = site.__parent__ while not IRootFolder.providedBy(parent): parent = parent.__parent__ return parent
def get_application(name): """get Application by the it's name.""" root = get_root_folder() app = root[name] if IApplication.providedBy(app): return app