Beispiel #1
0
def install_deferred():
    # Temporarily patch fiveconfigure with findProducts able to see only
    # products under reload paths and execute Five configuration directives
    import sauna.reload
    import Products.Five.fiveconfigure
    setattr(Products.Five.fiveconfigure, "findProducts", findDeferredProducts)
    load_config("fiveconfigure.zcml", sauna.reload)
    setattr(Products.Five.fiveconfigure, "findProducts", findProducts)

    # Five pushes old-style product initializations into
    # Products._packages_to_initialize-list. We must loop through that list
    # for our reloaded packages and try to install them.
    import Products
    from App.config import getConfiguration
    from OFS.Application import install_package
    from Zope2.App.startup import app
    # FIXME: Is this really the only way to get our app-object?
    app = app()  # XXX: Help! Should we use use app._p_jar-stuff around here?
    debug_mode = getConfiguration().debug_mode
    from sauna.reload import reload_paths
    for module, init_func in getattr(Products, "_packages_to_initialize", []):
        if getattr(module, "__file__") in reload_paths:
            install_package(app, module, init_func, raise_exc=debug_mode)
    if hasattr(Products, "_packages_to_initialize"):
        del Products._packages_to_initialize
Beispiel #2
0
def installDeferred():
    """
    Temporarily patch fiveconfigure with a findProducts-method,
    which is able to see only the products under the reload paths
    and execute Five configuration directives for those.
    """
    import sauna.reload
    try:
        # Zope 2.13
        import OFS.metaconfigure
        setattr(OFS.metaconfigure, 'findProducts', findDeferredProducts)
        load_config('fiveconfigure.zcml', sauna.reload)
        setattr(OFS.metaconfigure, 'findProducts', findProducts)
    except ImportError:
        # Zope 2.12
        import Products.Five.fiveconfigure
        setattr(Products.Five.fiveconfigure, 'findProducts',
                findDeferredProducts)
        load_config('fiveconfigure.zcml', sauna.reload)
        setattr(Products.Five.fiveconfigure, 'findProducts', findProducts)

    # Five pushes old-style product initializations into
    # Products._packages_to_initialize-list.
    # We must loop through that list to find the reloaded packages
    # and try to install them when found.
    from App.config import getConfiguration
    from OFS.Application import install_package
    from Zope2.App.startup import app
    app = app()
    debug_mode = getConfiguration().debug_mode
    from sauna.reload import reload_paths
    try:
        # Zope 2.13
        import OFS.metaconfigure
        # We iterate a copy of packages_to_initialize,
        # because install_package mutates the original.
        packages_to_initialize = [
            info for info in getattr(OFS.metaconfigure,
                                     '_packages_to_initialize', [])
        ]
        for module, init_func in packages_to_initialize:
            if getattr(module, '__file__') in reload_paths:
                install_package(app, module, init_func, raise_exc=debug_mode)
    except ImportError:
        # Zope 2.12
        import Products
        # We iterate a copy of packages_to_initialize,
        # because install_package mutates the original.
        packages_to_initialize = [
            info for info in getattr(Products, '_packages_to_initialize', [])
        ]
        for module, init_func in packages_to_initialize:
            if getattr(module, '__file__') in reload_paths:
                install_package(app, module, init_func, raise_exc=debug_mode)
        if hasattr(Products, '_packages_to_initialize'):
            del Products._packages_to_initialize
def installDeferred():
    """
    Temporarily patch fiveconfigure with a findProducts-method,
    which is able to see only the products under the reload paths
    and execute Five configuration directives for those.
    """
    import sauna.reload
    try:
        # Zope 2.13
        import OFS.metaconfigure
        setattr(OFS.metaconfigure, 'findProducts', findDeferredProducts)
        load_config('fiveconfigure.zcml', sauna.reload)
        setattr(OFS.metaconfigure, 'findProducts', findProducts)
    except ImportError:
        # Zope 2.12
        import Products.Five.fiveconfigure
        setattr(Products.Five.fiveconfigure, 'findProducts',
                findDeferredProducts)
        load_config('fiveconfigure.zcml', sauna.reload)
        setattr(Products.Five.fiveconfigure, 'findProducts', findProducts)

    # Five pushes old-style product initializations into
    # Products._packages_to_initialize-list.
    # We must loop through that list to find the reloaded packages
    # and try to install them when found.
    from App.config import getConfiguration
    from OFS.Application import install_package
    from Zope2.App.startup import app
    app = app()
    debug_mode = getConfiguration().debug_mode
    from sauna.reload import reload_paths
    try:
        # Zope 2.13
        import OFS.metaconfigure
        # We iterate a copy of packages_to_initialize,
        # because install_package mutates the original.
        packages_to_initialize = [info for info in getattr(
            OFS.metaconfigure, '_packages_to_initialize', [])]
        for module, init_func in packages_to_initialize:
            if getattr(module, '__file__') in reload_paths:
                install_package(app, module, init_func, raise_exc=debug_mode)
    except ImportError:
        # Zope 2.12
        import Products
        # We iterate a copy of packages_to_initialize,
        # because install_package mutates the original.
        packages_to_initialize = [info for info in getattr(
            Products, '_packages_to_initialize', [])]
        for module, init_func in packages_to_initialize:
            if getattr(module, '__file__') in reload_paths:
                install_package(app, module, init_func, raise_exc=debug_mode)
        if hasattr(Products, '_packages_to_initialize'):
            del Products._packages_to_initialize