Exemplo n.º 1
0
def upgrade(app, args):
    # Display all messages on stderr
    logger.setLevel(logging.DEBUG)
    logger.handlers[0].setLevel(logging.DEBUG)

    existing = app.objectValues('Plone Site')
    site = existing and existing[0] or None
    if site is None:
        logger.error("No Plone site found in the database.")
        sys.exit(1)

    _, site = _setup(app, site)

    from intranett.policy.config import config

    logger.info("Starting the upgrade.\n\n")
    setup = site.portal_setup
    config.run_all_upgrades(setup)
    logger.info("Ran upgrade steps.")

    # Recook resources, as some CSS/JS files might have changed.
    # TODO: We could try to determine if this is needed in some way
    site.portal_javascripts.cookResources()
    site.portal_css.cookResources()
    logger.info("Resources recooked.")

    transaction.get().note('Upgraded profiles and recooked resources.')
    transaction.get().commit()
    sys.exit(0)
Exemplo n.º 2
0
def upgrade(app, args):
    # Display all messages on stderr
    logger.setLevel(logging.DEBUG)
    logger.handlers[0].setLevel(logging.DEBUG)

    existing = app.objectValues('Plone Site')
    site = existing and existing[0] or None
    if site is None:
        logger.error("No Plone site found in the database.")
        sys.exit(1)

    _, site = _setup(app, site)

    from intranett.policy.config import config

    logger.info("Starting the upgrade.\n\n")
    setup = site.portal_setup
    config.run_all_upgrades(setup)
    logger.info("Ran upgrade steps.")

    # Recook resources, as some CSS/JS files might have changed.
    # TODO: We could try to determine if this is needed in some way
    site.portal_javascripts.cookResources()
    site.portal_css.cookResources()
    logger.info("Resources recooked.")

    transaction.get().note('Upgraded profiles and recooked resources.')
    transaction.get().commit()
    sys.exit(0)
Exemplo n.º 3
0
 def test_do_upgrades(self):
     portal = self.layer['portal']
     setup = getToolByName(portal, "portal_setup")
     setRoles(portal, TEST_USER_ID, ['Manager'])
     setup.setLastVersionForProfile(config.policy_profile, '6')
     config.run_all_upgrades(setup)
     # There are no more upgrade steps available
     upgrades = setup.listUpgrades(config.policy_profile)
     self.assertEqual(upgrades, [])
Exemplo n.º 4
0
    def test_upgrades(self):
        self.importFile(__file__, 'fourtysix.zexp')
        portal = getattr(self.layer['app'], self.site_id)

        # TODO - we should do this in a layer
        self.layer['portal'] = portal
        setSite(portal)
        self.portal = portal

        # Adjust for some things changed by the testing infrastructure
        portal.setTitle('intranett.no')

        portal.portal_migration.upgrade(swallow_errors=False)
        setup = getToolByName(portal, "portal_setup")
        config.run_all_upgrades(setup, skip_policy=True)

        # run the upgrade steps for the policy
        request = self.layer['request']
        request['profile_id'] = config.policy_profile
        upgrades = setup.listUpgrades(config.policy_profile)
        for u in upgrades:
            dest = u['sdest']
            before_name = "before_%s" % dest
            before = getattr(self, before_name, None)
            if before is not None:
                before()
            request.form['upgrades'] = [u['id']]
            setup.manage_doUpgrades(request=request)
            after_name = "after_%s" % dest
            after = getattr(self, after_name, None)
            self.assertFalse(
                after is None,
                "The %s class is missing the %s function to check the upgrade "
                "to version %s" % (self.__class__.__name__, after_name, dest))
            after()

        # test the end result
        upgrades = ensure_no_upgrades(setup)
        for profile, steps in upgrades.items():
            self.assertEquals(len(steps), 0,
                              "Found unexpected upgrades: %s" % steps)

        login(self.layer['app'], SITE_OWNER_NAME)
        diff = self.export()
        remaining = self.parse_diff(diff)

        def _print(values):  # pragma: no cover
            for v in values:
                pprint(v.split('\n'))

        self.assertEqual(set(remaining.keys()), set([]),
                         _print(remaining.values()))
Exemplo n.º 5
0
    def test_upgrades(self):
        self.importFile(__file__, 'fourtysix.zexp')
        portal = getattr(self.layer['app'], self.site_id)

        # TODO - we should do this in a layer
        self.layer['portal'] = portal
        setSite(portal)
        self.portal = portal

        # Adjust for some things changed by the testing infrastructure
        portal.setTitle('intranett.no')

        portal.portal_migration.upgrade(swallow_errors=False)
        setup = getToolByName(portal, "portal_setup")
        config.run_all_upgrades(setup, skip_policy=True)

        # run the upgrade steps for the policy
        request = self.layer['request']
        request['profile_id'] = config.policy_profile
        upgrades = setup.listUpgrades(config.policy_profile)
        for u in upgrades:
            dest = u['sdest']
            before_name = "before_%s" % dest
            before = getattr(self, before_name, None)
            if before is not None:
                before()
            request.form['upgrades'] = [u['id']]
            setup.manage_doUpgrades(request=request)
            after_name = "after_%s" % dest
            after = getattr(self, after_name, None)
            self.assertFalse(after is None,
                "The %s class is missing the %s function to check the upgrade "
                "to version %s" % (self.__class__.__name__,
                    after_name, dest))
            after()

        # test the end result
        upgrades = ensure_no_upgrades(setup)
        for profile, steps in upgrades.items():
            self.assertEquals(len(steps), 0,
                              "Found unexpected upgrades: %s" % steps)

        login(self.layer['app'], SITE_OWNER_NAME)
        diff = self.export()
        remaining = self.parse_diff(diff)

        def _print(values): # pragma: no cover
            for v in values:
                pprint(v.split('\n'))
        self.assertEqual(set(remaining.keys()), set([]),
            _print(remaining.values()))