Logo Search packages:      
Sourcecode: zope-cmfmember version File versions  Download package

def CMFMember::tools::control::ControlTool::upgrade (   self,
  REQUEST = None,
  dry_run = None,
  swallow_errors = 1,
  default_member_type = DEFAULT_TYPE,
  default_workflow = None,
  upgrade_workflows = False,
  configure_atse = False 
)

perform the upgrade 

Definition at line 403 of file control.py.

                                                               :
        """ perform the upgrade """

        # keep it simple
        out = []
        
        # reinstall CMFMember default workflows
        if upgrade_workflows:
            setupWorkflow(getToolByName(self, 'portal_url'), out, force_reinstall=True)
            out.append(('Workflows reinstalled', zLOG.INFO))

        # Set the default workflow for the selected default member type
        if default_workflow:
            wf_tool = getToolByName(self, 'portal_workflow')
            wf_tool.setChainForPortalTypes((default_member_type,), default_workflow)
            wf_tool.updateRoleMappings()
            out.append(('Workflow for %s  set to %s' % (default_member_type,
                                                        default_workflow),
                        zLOG.INFO))
            
        self._check()
        failed = 0
        if dry_run:
            out.append(("Dry run selected.", zLOG.INFO))

        if REQUEST is not None:
            newv = REQUEST.get('force_instance_version', self.getInstanceVersion())
        else:
            newv = self.getInstanceVersion()

        out.append(("Starting the migration from "
                    "version: %s" % newv, zLOG.INFO))

        # reinstall the CMFMember product, if necessary
        qi_tool = getToolByName(self, 'portal_quickinstaller')
        inst_vers = [prod['installedVersion'] \
                     for prod in qi_tool.listInstalledProducts() \
                     if prod['id'] == 'CMFMember']
        fs_vers = qi_tool.getProductVersion('CMFMember')
    
        if len(inst_vers) and inst_vers[0] != fs_vers:
            out.append(('Reinstalling CMFMember Product', zLOG.INFO))
            qi_tool.reinstallProducts(['CMFMember'])

        while newv is not None:
            out.append(("Attempting to upgrade from: %s" % newv, zLOG.INFO))
            # commit work in progress between each version
            #get_transaction().commit(1)
            # if we modify the portal root and commit a sub transaction
            # the skin data will disappear, explicitly set it up on each
            # subtrans, the alternative is to traverse again to the root on
            # after each which will trigger the normal implicit skin setup.
            aq_parent( aq_inner( self ) ).setupCurrentSkin()
            try:
                newv, msgs = self._upgrade(newv)
                if msgs:
                    for msg in msgs:
                        # if string make list
                        if type(msg) == type(''):
                            msg = [msg,]
                        # if no status, add one
                        if len(msg) == 1:
                            msg.append(zLOG.INFO)
                        out.append(msg)
                if newv is not None:
                    out.append(("Upgrade to: %s, completed" % newv, zLOG.INFO))
                    self.setInstanceVersion(newv)

            except:
                out.append(("Upgrade aborted", zLOG.ERROR))
                out.append(("Error type: %s" % sys.exc_type, zLOG.ERROR))
                out.append(("Error value: %s" % sys.exc_value, zLOG.ERROR))
                for line in traceback.format_tb(sys.exc_traceback):
                    out.append((line, zLOG.ERROR))

                # set newv to None
                # to break the loop
                newv = None
                failed = 1
                if swallow_errors:
                    # abort transaction to safe the zodb
                    get_transaction().abort()
                else:
                    for msg, sev in out: log(msg, severity=sev)
                    raise

        out.append(("End of upgrade path, migration has finished", zLOG.INFO))

        if self.needUpgrading():
            out.append((("The upgrade path did NOT reach "
                        "current version"), zLOG.PROBLEM))
            out.append(("Migration has failed", zLOG.PROBLEM))
        else:
            mdc = getToolByName(self, 'portal_memberdata')
            if default_member_type != mdc.getTypeName():
                mdc.setDefaultType(default_member_type)
                out.append((('Set new default type for registration: %s' %default_member_type), zLOG.INFO))
        
            self._configureATSchemaEditorNG(mdc)
                
            out.append((("Your ZODB and Filesystem Plone "
                         "instances are now up-to-date."), zLOG.INFO))

        # do this once all the changes have been done
        if not failed and self.needRecatalog():
            try:
                self.portal_catalog.refreshCatalog()
                self._needRecatalog = 0
            except:
                out.append(("Exception was thrown while cataloging",
                            zLOG.ERROR))
                out += traceback.format_tb(sys.exc_traceback)
                if not swallow_errors:
                    for msg, sev in out: log(msg, severity=sev)
                    raise

        if not failed and self.needUpdateRole():
            try:
                self.portal_workflow.updateRoleMappings()
                self._needUpdateRole = 0
            except:
                out.append((("Exception was thrown while updating "
                             "role mappings"), zLOG.ERROR))
                out += traceback.format_tb(sys.exc_traceback)
                if not swallow_errors:
                    for msg, sev in out: log(msg, severity=sev)
                    raise
                    
        
        if dry_run:
            out.append(("Dry run selected, transaction aborted", zLOG.INFO))
            # abort all work done in this transaction, this roles back work
            # done in previous sub transactions
            get_transaction().abort()

        # log all this to the ZLOG
        for msg, sev in out:
            log(msg, severity=sev)

        self._log = out

        if REQUEST:
            return REQUEST.RESPONSE.redirect(self.absolute_url() + '/prefs_cmfmember_migration')
        
    def getConfiglets(self):


Generated by  Doxygen 1.6.0   Back to index