示例#1
0
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
示例#2
0
def handle_grokapplication(dotted_path, ob=None):
    """Determine, whether the given path/obj references a Grok application.
    """
    if ob is None:
        try:
            ob = resolve(dotted_path)
        except ImportError:
            None
    try:
        if not IApplication.implementedBy(ob):
            return None
    except TypeError:
        return None
    return DocGrokGrokApplication(dotted_path)
示例#3
0
def get_application(name):
    """get Application by the it's name."""
    root = get_root_folder()
    app = root[name]
    if IApplication.providedBy(app):
       return app