Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes
CMFPlone.MigrationTool.MigrationTool Class Reference
Inheritance diagram for CMFPlone.MigrationTool.MigrationTool:
Inheritance graph
[legend]
Collaboration diagram for CMFPlone.MigrationTool.MigrationTool:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def om_icons
def getInstanceVersion
 Public methods.
def setInstanceVersion
def knownVersions
def unsupportedVersion
def getFileSystemVersion
def getFSVersionTuple
def getInstanceVersionTuple
def needUpgrading
def coreVersions
def coreVersionsList
def needUpdateRole
def needRecatalog
def getProductInfo
def getPILVersion
def upgrade

Static Public Attributes

string id = 'portal_migration'
string meta_type = 'Plone Migration Tool'
string toolicon = 'skins/plone_images/site_icon.gif'
tuple manage_options
tuple security = ClassSecurityInfo()
tuple manage_migrate = DTMLFile('www/migrationRun', globals())
tuple manage_overview = DTMLFile('www/migrationTool', globals())
tuple manage_results = DTMLFile('www/migrationResults', globals())
tuple upgrade = postonly(upgrade)

Private Member Functions

def _check
 Private methods.
def _upgrade

Private Attributes

 _version
 _needRecatalog
 _needUpdateRole

Static Private Attributes

tuple __implements__ = (PloneBaseTool.__implements__, SimpleItem.__implements__, )
int _needRecatalog = 0
int _needUpdateRole = 0

Detailed Description

Handles migrations between Plone releases

Definition at line 25 of file MigrationTool.py.


Member Function Documentation

Private methods.

Are we inside a Plone site?  Are we allowed? 

Definition at line 307 of file MigrationTool.py.

00307 
00308     def _check(self):
00309         """ Are we inside a Plone site?  Are we allowed? """
00310         if getattr(self,'portal_url', []) == []:
00311             raise AttributeError, 'You must be in a Plone site to migrate.'

Here is the caller graph for this function:

def CMFPlone.MigrationTool.MigrationTool._upgrade (   self,
  version 
) [private]

Definition at line 312 of file MigrationTool.py.

00312 
00313     def _upgrade(self, version):
00314         version = version.lower()
00315         if not _upgradePaths.has_key(version):
00316             return None, ("Migration completed at version %s." % version,)
00317 
00318         newversion, function = _upgradePaths[version]
00319         # This means a now unsupported migration path has been triggered
00320         if function is False:
00321             return None, ("Migration stopped at version %s." % version,)
00322         res = function(self.aq_parent)
00323         return newversion, res

Here is the caller graph for this function:

Useful core information 

Definition at line 127 of file MigrationTool.py.

00127 
00128     def coreVersions(self):
00129         """ Useful core information """
00130         vars = {}
00131         cp = self.Control_Panel
00132         vars['Zope'] = cp.version_txt
00133         vars['Python'] = cp.sys_version
00134         vars['Platform'] = cp.sys_platform
00135         vars['Plone Instance'] = self.getInstanceVersion()
00136         vars['Plone File System'] = self.getFileSystemVersion()
00137         vars['CMF'] = cp.Products.CMFCore.version
00138         vars['Debug mode'] = DevelopmentMode and 'Yes' or 'No'
00139         try:
00140             from PIL.Image import VERSION
00141         except ImportError:
00142             VERSION = ''
00143         vars['PIL'] = VERSION
00144         return vars

Here is the call graph for this function:

Here is the caller graph for this function:

Useful core information 

Definition at line 146 of file MigrationTool.py.

00146 
00147     def coreVersionsList(self):
00148         """ Useful core information """
00149         res = self.coreVersions().items()
00150         res.sort()
00151         return res

Here is the call graph for this function:

The version this instance of plone is on 

Definition at line 105 of file MigrationTool.py.

00105 
00106     def getFileSystemVersion(self):
00107         """ The version this instance of plone is on """
00108         return self.Control_Panel.Products.CMFPlone.version.lower()

Here is the caller graph for this function:

returns tuple representing filesystem version 

Definition at line 110 of file MigrationTool.py.

00110 
00111     def getFSVersionTuple(self):
00112         """ returns tuple representing filesystem version """
00113         v_str = self.getFileSystemVersion()
00114         return versionTupleFromString(v_str)

Here is the call graph for this function:

Public methods.

versions methods

The version this instance of plone is on 

Definition at line 77 of file MigrationTool.py.

00077 
00078     def getInstanceVersion(self):
00079         """ The version this instance of plone is on """
00080         if getattr(self, '_version', None) is None:
00081             self.setInstanceVersion(self.getFileSystemVersion())
00082         return self._version.lower()

Here is the call graph for this function:

Here is the caller graph for this function:

returns tuple representing instance version 

Definition at line 116 of file MigrationTool.py.

00116 
00117     def getInstanceVersionTuple(self):
00118         """ returns tuple representing instance version """
00119         v_str = self.getInstanceVersion()
00120         return versionTupleFromString(v_str)

Here is the call graph for this function:

The version of the installed Python Imaging Library.

Definition at line 180 of file MigrationTool.py.

00180 
00181     def getPILVersion(self):
00182         """The version of the installed Python Imaging Library."""
00183         log_deprecated("getPILVersion is deprecated and will be removed in "
00184                        "Plone 4.0. Please use coreVersions instead.")
00185         try:
00186             from PIL.Image import VERSION
00187         except ImportError:
00188             VERSION = None
00189         return VERSION

Here is the call graph for this function:

Provide information about installed products for error reporting

Definition at line 163 of file MigrationTool.py.

00163 
00164     def getProductInfo(self):
00165         """Provide information about installed products for error reporting"""
00166         zope_products = self.getPhysicalRoot().Control_Panel.Products.objectValues()
00167         installed_products = getToolByName(self, 'portal_quickinstaller').listInstalledProducts(showHidden=1)
00168         products = {}
00169         for p in zope_products:
00170             product_info = {'id':p.id, 'version':p.version}
00171             for ip in installed_products:
00172                 if ip['id'] == p.id:
00173                     product_info['status'] = ip['status']
00174                     product_info['hasError'] = ip['hasError']
00175                     product_info['installedVersion'] = ip['installedVersion']
00176                     break
00177             products[p.id] = product_info
00178         return products

Here is the call graph for this function:

All known version ids, except current one and unsupported
   migration paths.

Definition at line 89 of file MigrationTool.py.

00089 
00090     def knownVersions(self):
00091         """All known version ids, except current one and unsupported
00092            migration paths.
00093         """
00094         versions = [k for k in _upgradePaths if _upgradePaths[k][1] != False]
00095         return versions

Does this thing now need recataloging? 

Definition at line 158 of file MigrationTool.py.

00158 
00159     def needRecatalog(self):
00160         """ Does this thing now need recataloging? """
00161         return self._needRecatalog

Here is the caller graph for this function:

Do roles need to be updated? 

Definition at line 153 of file MigrationTool.py.

00153 
00154     def needUpdateRole(self):
00155         """ Do roles need to be updated? """
00156         return self._needUpdateRole

Here is the caller graph for this function:

Need upgrading? 

Definition at line 122 of file MigrationTool.py.

00122 
00123     def needUpgrading(self):
00124         """ Need upgrading? """
00125         return self.getInstanceVersion() != self.getFileSystemVersion()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 54 of file MigrationTool.py.

00054 
00055     def om_icons(self):
00056         icons = ({
00057                     'path':'misc_/CMFPlone/tool.gif',
00058                     'alt':self.meta_type,
00059                     'title':self.meta_type,
00060                  },)
00061         if self.needUpgrading() \
00062            or self.needUpdateRole() \
00063            or self.needRecatalog():
00064             icons = icons + ({
00065                      'path':'misc_/PageTemplates/exclamation.gif',
00066                      'alt':'Error',
00067                      'title':'This Plone instance needs updating'
00068                   },)
00069 
00070         return icons

Here is the call graph for this function:

The version this instance of plone is on 

Definition at line 84 of file MigrationTool.py.

00084 
00085     def setInstanceVersion(self, version):
00086         """ The version this instance of plone is on """
00087         self._version = version

Here is the caller graph for this function:

Is the current instance version known to be a no longer supported
   version for migrations.

Definition at line 97 of file MigrationTool.py.

00097 
00098     def unsupportedVersion(self):
00099         """Is the current instance version known to be a no longer supported
00100            version for migrations.
00101         """
00102         versions = [k for k in _upgradePaths if _upgradePaths[k][1] is False]
00103         return self._version in versions

def CMFPlone.MigrationTool.MigrationTool.upgrade (   self,
  REQUEST = None,
  dry_run = None,
  swallow_errors = 1 
)
perform the upgrade 

Definition at line 191 of file MigrationTool.py.

00191 
00192     def upgrade(self, REQUEST=None, dry_run=None, swallow_errors=1):
00193         """ perform the upgrade """
00194         # keep it simple
00195         out = []
00196 
00197         self._check()
00198 
00199         if dry_run:
00200             out.append(("Dry run selected.", logging.INFO))
00201 
00202         # either get the forced upgrade instance or the current instance
00203         newv = getattr(REQUEST, "force_instance_version",
00204                        self.getInstanceVersion())
00205 
00206         out.append(("Starting the migration from "
00207                     "version: %s" % newv, logging.INFO))
00208         while newv is not None:
00209             out.append(("Attempting to upgrade from: %s" % newv, logging.INFO))
00210             try:
00211                 newv, msgs = self._upgrade(newv)
00212                 if msgs:
00213                     for msg in msgs:
00214                         # if string make list
00215                         if isinstance(msg, basestring):
00216                             msg = [msg,]
00217                         # if no status, add one
00218                         if len(msg) == 1:
00219                             msg.append(logging.INFO)
00220                         out.append(msg)
00221                 if newv is not None:
00222                     out.append(("Upgrade to: %s, completed" % newv, logging.INFO))
00223                     self.setInstanceVersion(newv)
00224 
00225             except ConflictError:
00226                 raise
00227             except:
00228                 out.append(("Upgrade aborted", logging.ERROR))
00229                 out.append(("Error type: %s" % sys.exc_type, logging.ERROR))
00230                 out.append(("Error value: %s" % sys.exc_value, logging.ERROR))
00231                 for line in traceback.format_tb(sys.exc_traceback):
00232                     out.append((line, logging.ERROR))
00233 
00234                 # set newv to None
00235                 # to break the loop
00236                 newv = None
00237                 if not swallow_errors:
00238                     for msg, sev in out: log(msg, severity=sev)
00239                     raise
00240                 else:
00241                     # abort transaction to safe the zodb
00242                     transaction.abort()
00243 
00244         out.append(("End of upgrade path, migration has finished", logging.INFO))
00245 
00246         if self.needUpgrading():
00247             out.append((("The upgrade path did NOT reach "
00248                         "current version"), logging.ERROR))
00249             out.append(("Migration has failed", logging.ERROR))
00250         else:
00251             out.append((("Your ZODB and Filesystem Plone "
00252                          "instances are now up-to-date."), logging.INFO))
00253 
00254         # do this once all the changes have been done
00255         if self.needRecatalog():
00256             try:
00257                 catalog = self.portal_catalog
00258                 # Reduce threshold for the reindex run
00259                 old_threshold = catalog.threshold
00260                 pg_threshold = getattr(catalog, 'pgthreshold', 0)
00261                 catalog.pgthreshold = 300
00262                 catalog.threshold = 2000
00263                 catalog.refreshCatalog(clear=1)
00264                 catalog.threshold = old_threshold
00265                 catalog.pgthreshold = pg_threshold
00266                 self._needRecatalog = 0
00267             except ConflictError:
00268                 raise
00269             except:
00270                 out.append(("Exception was thrown while cataloging",
00271                             logging.ERROR))
00272                 for line in traceback.format_tb(sys.exc_traceback):
00273                     out.append((line, logging.ERROR))
00274                 if not swallow_errors:
00275                     for msg, sev in out: log(msg, severity=sev)
00276                     raise
00277 
00278         if self.needUpdateRole():
00279             try:
00280                 self.portal_workflow.updateRoleMappings()
00281                 self._needUpdateRole = 0
00282             except ConflictError:
00283                 raise
00284             except:
00285                 out.append((("Exception was thrown while updating "
00286                              "role mappings"), logging.ERROR))
00287                 for line in traceback.format_tb(sys.exc_traceback):
00288                     out.append((line, logging.ERROR))
00289                 if not swallow_errors:
00290                     for msg, sev in out: log(msg, severity=sev)
00291                     raise
00292 
00293         if dry_run:
00294             out.append(("Dry run selected, transaction aborted", logging.INFO))
00295             transaction.abort()
00296 
00297         # log all this
00298         for msg, sev in out: log(msg, severity=sev)
00299         try:
00300             return self.manage_results(self, out=out)
00301         except NameError:
            pass

Here is the call graph for this function:


Member Data Documentation

tuple CMFPlone.MigrationTool.MigrationTool.__implements__ = (PloneBaseTool.__implements__, SimpleItem.__implements__, ) [static, private]

Definition at line 34 of file MigrationTool.py.

Definition at line 36 of file MigrationTool.py.

Definition at line 265 of file MigrationTool.py.

Definition at line 37 of file MigrationTool.py.

Definition at line 280 of file MigrationTool.py.

Definition at line 86 of file MigrationTool.py.

string CMFPlone.MigrationTool.MigrationTool.id = 'portal_migration' [static]

Definition at line 30 of file MigrationTool.py.

tuple CMFPlone.MigrationTool.MigrationTool.manage_migrate = DTMLFile('www/migrationRun', globals()) [static]

Definition at line 49 of file MigrationTool.py.

Initial value:
(
        { 'label' : 'Upgrade', 'action' : 'manage_migrate' },
        )

Definition at line 39 of file MigrationTool.py.

tuple CMFPlone.MigrationTool.MigrationTool.manage_overview = DTMLFile('www/migrationTool', globals()) [static]

Definition at line 50 of file MigrationTool.py.

tuple CMFPlone.MigrationTool.MigrationTool.manage_results = DTMLFile('www/migrationResults', globals()) [static]

Definition at line 51 of file MigrationTool.py.

string CMFPlone.MigrationTool.MigrationTool.meta_type = 'Plone Migration Tool' [static]

Definition at line 31 of file MigrationTool.py.

tuple CMFPlone.MigrationTool.MigrationTool.security = ClassSecurityInfo() [static]

Definition at line 43 of file MigrationTool.py.

string CMFPlone.MigrationTool.MigrationTool.toolicon = 'skins/plone_images/site_icon.gif' [static]

Definition at line 32 of file MigrationTool.py.

Definition at line 302 of file MigrationTool.py.


The documentation for this class was generated from the following file: