Пример #1
0
    def manage_doUpgrades(self, request=None):
        """Perform all selected upgrade steps.
        """
        if request is None:
            request = self.REQUEST
        logger = logging.getLogger('GenericSetup')
        steps_to_run = request.form.get('upgrades', [])
        profile_id = request.get('profile_id', '')
        for step_id in steps_to_run:
            step = _upgrade_registry.getUpgradeStep(profile_id, step_id)
            if step is not None:
                step.doStep(self)
                msg = "Ran upgrade step %s for profile %s" % (step.title,
                                                              profile_id)
                logger.log(logging.INFO, msg)

        # XXX should be a bit smarter about deciding when to up the
        #     profile version
        profile_info = _profile_registry.getProfileInfo(profile_id)
        version = profile_info.get('version', None)
        if version is not None:
            self.setLastVersionForProfile(profile_id, version)

        url = self.absolute_url()
        request.RESPONSE.redirect("%s/manage_upgrades?saved=%s" % (url, profile_id))
Пример #2
0
    def manage_doUpgrades(self, request=None):
        """Perform all selected upgrade steps.
        """
        if request is None:
            request = self.REQUEST
        logger = logging.getLogger('GenericSetup')
        steps_to_run = request.form.get('upgrades', [])
        profile_id = request.get('profile_id', '')
        for step_id in steps_to_run:
            step = _upgrade_registry.getUpgradeStep(profile_id, step_id)
            if step is not None:
                step.doStep(self)
                msg = "Ran upgrade step %s for profile %s" % (step.title,
                                                              profile_id)
                logger.log(logging.INFO, msg)

        # XXX should be a bit smarter about deciding when to up the
        #     profile version
        profile_info = _profile_registry.getProfileInfo(profile_id)
        version = profile_info.get('version', None)
        if version is not None:
            self.setLastVersionForProfile(profile_id, version)

        url = self.absolute_url()
        request.RESPONSE.redirect("%s/manage_upgrades?saved=%s" %
                                  (url, profile_id))
Пример #3
0
    def _getImportContext(self, context_id, should_purge=None):

        """ Crack ID and generate appropriate import context.
        """
        encoding = self.getEncoding()

        if context_id.startswith('profile-'):

            context_id = context_id[len('profile-'):]
            info = _profile_registry.getProfileInfo(context_id)

            if info.get('product'):
                path = os.path.join(self._getProductPath(info['product'])
                                   , info['path'])
            else:
                path = info['path']
            if should_purge is None:
                should_purge = (info.get('type') != EXTENSION)
            return DirectoryImportContext(self, path, should_purge, encoding)

        # else snapshot
        context_id = context_id[len('snapshot-'):]
        if should_purge is None:
            should_purge = True
        return SnapshotImportContext(self, context_id, should_purge, encoding)
Пример #4
0
    def _getImportContext(self, context_id, should_purge=None):
        """ Crack ID and generate appropriate import context.
        """
        encoding = self.getEncoding()

        if context_id.startswith('profile-'):

            context_id = context_id[len('profile-'):]
            info = _profile_registry.getProfileInfo(context_id)

            if info.get('product'):
                path = os.path.join(self._getProductPath(info['product']),
                                    info['path'])
            else:
                path = info['path']
            if should_purge is None:
                should_purge = (info.get('type') != EXTENSION)
            return DirectoryImportContext(self, path, should_purge, encoding)

        elif context_id.startswith('snapshot-'):
            context_id = context_id[len('snapshot-'):]
            if should_purge is None:
                should_purge = True
            return SnapshotImportContext(self, context_id, should_purge,
                                         encoding)
        else:
            raise KeyError, 'Unknown context "%s"' % context_id
Пример #5
0
    def setImportContext(self, context_id, encoding=None):
        """ See ISetupTool.
        """
        warn('setImportContext is deprecated.  Use setBaselineContext to '
             'specify the baseline context, and/or runImportStepFromProfile '
             'to run the steps from a specific import context.',
             DeprecationWarning, stacklevel=2)
        self._import_context_id = context_id

        context_type = BASE  # snapshots are always baseline contexts
        if context_id.startswith('profile-'):
            profile_info = _profile_registry.getProfileInfo(context_id[8:])
            context_type = profile_info['type']

        if context_type == BASE:
            self.setBaselineContext(context_id, encoding)
Пример #6
0
    def setImportContext(self, context_id, encoding=None):
        """ See ISetupTool.
        """
        warn('setImportContext is deprecated.  Use setBaselineContext to '
             'specify the baseline context, and/or runImportStepsFromContext '
             'to run the steps from a specific import context.',
             DeprecationWarning, stacklevel=2)
        self._import_context_id = context_id

        context_type = BASE  # snapshots are always baseline contexts
        if context_id.startswith('profile-'):
            profile_info = _profile_registry.getProfileInfo(context_id[8:])
            context_type = profile_info['type']

        if context_type == BASE:
            self.setBaselineContext(context_id, encoding)
Пример #7
0
    def _getImportContext(self, context_id):
        """ Crack ID and generate appropriate import context.
        """
        if context_id.startswith('profile-'):

            context_id = context_id[len('profile-'):]
            info = _profile_registry.getProfileInfo(context_id)

            if info.get('product'):
                path = os.path.join(self._getProductPath(info['product']),
                                    info['path'])
            else:
                path = info['path']

            return DirectoryImportContext(self, path)

        # else snapshot
        context_id = context_id[len('snapshot-'):]
        return SnapshotImportContext(self, context_id)
Пример #8
0
    def _getImportContext( self, context_id ):

        """ Crack ID and generate appropriate import context.
        """
        if context_id.startswith( 'profile-' ):

            context_id = context_id[ len( 'profile-' ): ]
            info = _profile_registry.getProfileInfo( context_id )

            if info.get( 'product' ):
                path = os.path.join( self._getProductPath( info[ 'product' ] )
                                   , info[ 'path' ] )
            else:
                path = info[ 'path' ]

            return DirectoryImportContext( self, path )

        # else snapshot
        context_id = context_id[ len( 'snapshot-' ): ]
        return SnapshotImportContext( self, context_id )
Пример #9
0
def addConfiguredSite(dispatcher, site_id, profile_id, RESPONSE=None):
    """ Add a CMFSite to 'dispatcher', configured according to 'profile_id'.
    """
    site = CMFSite(site_id)
    dispatcher._setObject(site_id, site)
    site = dispatcher._getOb(site_id)

    setup_tool = SetupTool()
    site._setObject('portal_setup', setup_tool)
    setup_tool = getToolByName(site, 'portal_setup')

    profile_info = profile_registry.getProfileInfo(profile_id)
    setup_tool.setProfileDirectory(profile_info['path'],
                                   profile_info.get('product'))

    setup_tool.runAllImportSteps()
    setup_tool.createSnapshot('initial_configuration')

    if RESPONSE is not None:
        RESPONSE.redirect('%s/manage_main?update_menu=1' %
                          dispatcher.absolute_url())
Пример #10
0
def addConfiguredSite( dispatcher, site_id, profile_id, RESPONSE=None ):

    """ Add a CMFSite to 'dispatcher', configured according to 'profile_id'.
    """
    site = CMFSite( site_id )
    dispatcher._setObject( site_id, site )
    site = dispatcher._getOb( site_id )

    setup_tool = SetupTool()
    site._setObject( 'portal_setup', setup_tool )
    setup_tool = getToolByName( site, 'portal_setup' )

    profile_info = profile_registry.getProfileInfo( profile_id )
    setup_tool.setProfileDirectory( profile_info[ 'path' ]
                                  , profile_info.get( 'product' )
                                  )

    setup_tool.runAllImportSteps()
    setup_tool.createSnapshot( 'initial_configuration' )

    if RESPONSE is not None:
        RESPONSE.redirect( '%s/manage_main?update_menu=1'
                         % dispatcher.absolute_url() )
Пример #11
0
 def getVersionForProfile(self, profile_id):
     """Return the registered filesystem version for the specified
     profile.
     """
     info = _profile_registry.getProfileInfo(profile_id)
     return info.get('version', 'unknown')
Пример #12
0
 def getVersionForProfile(self, profile_id):
     """Return the registered filesystem version for the specified
     profile.
     """
     info = _profile_registry.getProfileInfo(profile_id)
     return info.get('version', 'unknown')
Пример #13
0
 def getProfileInfo(self, profile_id):
     if profile_id.startswith("profile-"):
         profile_id = profile_id[len('profile-'):]
     elif profile_id.startswith("snapshot-"):
         profile_id = profile_id[len('snapshot-'):]
     return _profile_registry.getProfileInfo(profile_id)
Пример #14
0
 def getProfileInfo(self, profile_id):
     """ Return the mapping for a specified profile.
     """
     return _profile_registry.getProfileInfo(profile_id)
Пример #15
0
 def getProfileInfo(self, profile_id):
     """ Return the mapping for a specified profile.
     """
     return _profile_registry.getProfileInfo(profile_id)