示例#1
0
def evolveTimetables(app):
    # This import holds references to substitute classes
    # so that they can be pickled after modules are restored.
    from schooltool.generations.evolve36 import model

    modules = ModulesSnapshot()

    modules.mock_module('schooltool.timetable')
    modules.mock(model.substitutes)

    builders = [
        SchoolTimetablesBuilder(),
        AppSchedulesBuilder(),
        AppTimetableCalendarBuilder(),
    ]

    for builder in builders:
        builder.read(app, BuildContext())

    modules.restore()

    for builder in builders:
        builder.clean(app, BuildContext())

    result = BuildContext()
    for builder in builders:
        built = builder.build(app, BuildContext(shared=result))
        result.update(built)

    # Pickle stuff
    transaction.savepoint()
示例#2
0
def evolveTimetables(app):
    # This import holds references to substitute classes
    # so that they can be pickled after modules are restored.
    from schooltool.generations.evolve36 import model

    modules = ModulesSnapshot()

    modules.mock_module('schooltool.timetable')
    modules.mock(model.substitutes)

    builders = [
        SchoolTimetablesBuilder(),
        AppSchedulesBuilder(),
        AppTimetableCalendarBuilder(),
        ]

    for builder in builders:
        builder.read(app, BuildContext())

    modules.restore()

    for builder in builders:
        builder.clean(app, BuildContext())

    result = BuildContext()
    for builder in builders:
        built = builder.build(app, BuildContext(shared=result))
        result.update(built)

    # Pickle stuff
    transaction.savepoint()
示例#3
0
def evolve(context):
    linkcatalogs.ensureEvolved(context)
    root = context.connection.root().get(ZopePublication.root_name, None)

    # Mock the renaming of zope.app.catalog and zope.app.intid to
    # zope.catalog and zope.intid.
    # This is for Critical Links deployments only - this part of Zope's evolution
    # was missed somehow.
    modules = ModulesSnapshot()
    modules.mock_module('zope.app.catalog')
    modules.mock_module('zope.app.catalog.interfaces')
    modules.mock_module('zope.app.catalog.catalog')
    modules.mock_module('zope.app.intid')
    modules.mock_module('zope.app.intid.interfaces')

    modules.mock_attr('zope.app.catalog.catalog', 'Catalog',
                      zope.catalog.catalog.Catalog)
    modules.mock_attr('zope.app.catalog.interfaces', 'ICatalog',
                      zope.catalog.interfaces.ICatalog)

    modules.mock_attr('zope.app.intid', 'IntIds', zope.intid.IntIds)
    modules.mock_attr('zope.app.intid.interfaces', 'IIntIds',
                      zope.intid.interfaces.IIntIds)

    # Proceed with normal evolution now.

    old_site = getSite()
    apps = findObjectsProviding(root, ISchoolToolApplication)
    for app in apps:
        setSite(app)
        sm = app.getSiteManager()
        default = traverse(app, '++etc++site/default')

        intids = getUtility(zope.intid.interfaces.IIntIds)
        intids._p_changed = True

        for key in CATALOG_KEYS:
            util = queryUtility(ICatalog, name=key, default=None)
            if util is None:
                continue
            name = util.__name__
            sm.unregisterUtility(util, ICatalog, key)
            del default[name]

    setSite(old_site)

    modules.restore()
示例#4
0
def evolve(context):
    linkcatalogs.ensureEvolved(context)
    root = context.connection.root().get(ZopePublication.root_name, None)

    # Mock the renaming of zope.app.catalog and zope.app.intid to
    # zope.catalog and zope.intid.
    # This is for Critical Links deployments only - this part of Zope's evolution
    # was missed somehow.
    modules = ModulesSnapshot()
    modules.mock_module('zope.app.catalog')
    modules.mock_module('zope.app.catalog.interfaces')
    modules.mock_module('zope.app.catalog.catalog')
    modules.mock_module('zope.app.intid')
    modules.mock_module('zope.app.intid.interfaces')

    modules.mock_attr('zope.app.catalog.catalog', 'Catalog', zope.catalog.catalog.Catalog)
    modules.mock_attr('zope.app.catalog.interfaces', 'ICatalog', zope.catalog.interfaces.ICatalog)

    modules.mock_attr('zope.app.intid', 'IntIds', zope.intid.IntIds)
    modules.mock_attr('zope.app.intid.interfaces', 'IIntIds', zope.intid.interfaces.IIntIds)

    # Proceed with normal evolution now.

    old_site = getSite()
    apps = findObjectsProviding(root, ISchoolToolApplication)
    for app in apps:
        setSite(app)
        sm = app.getSiteManager()
        default = traverse(app, '++etc++site/default')

        intids = getUtility(zope.intid.interfaces.IIntIds)
        intids._p_changed = True

        for key in CATALOG_KEYS:
            util = queryUtility(ICatalog, name=key, default=None)
            if util is None:
                continue
            name = util.__name__
            sm.unregisterUtility(util, ICatalog, key)
            del default[name]

    setSite(old_site)

    modules.restore()