Back to index

plone3  3.1.7
Functions | Variables
CMFPlone.migrations.migration_util Namespace Reference

Functions

def safeEditProperty
def safeGetMemberDataTool
def addLinesToProperty
def saveCloneActions
def testSkinLayer
def cleanupSkinPath
def installOrReinstallProduct
def loadMigrationProfile

Variables

list _marker = []

Function Documentation

def CMFPlone.migrations.migration_util.addLinesToProperty (   obj,
  key,
  values 
)

Definition at line 26 of file migration_util.py.

00026 
00027 def addLinesToProperty(obj, key, values):
00028     if obj.hasProperty(key):
00029         data = getattr(obj, key)
00030         if type(data) is TupleType:
00031             data = list(data)
00032         if type(values) is ListType:
00033             data.extend(values)
00034         else:
00035             data.append(values)
00036         obj._updateProperty(key, data)
00037     else:
00038         if type(values) is not ListType:
00039             values = [values]
00040         obj._setProperty(key, values, 'lines')

def CMFPlone.migrations.migration_util.cleanupSkinPath (   portal,
  skinName,
  test = 1 
)
Remove invalid skin layers from skins

Definition at line 66 of file migration_util.py.

00066 
00067 def cleanupSkinPath(portal, skinName, test=1):
00068    """Remove invalid skin layers from skins"""
00069    skinstool = getToolByName(portal, 'portal_skins')
00070    selections = skinstool._getSelections()
00071    old_path = selections[skinName].split(',')
00072    new_path = []
00073    for layer in old_path:
00074       if layer and testSkinLayer(skinstool, layer):
00075          new_path.append(layer)
00076    skinstool.addSkinSelection(skinName, ','.join(new_path), test=test)

Here is the call graph for this function:

def CMFPlone.migrations.migration_util.installOrReinstallProduct (   portal,
  product_name,
  out,
  hidden = False 
)
Installs a product

If product is already installed test if it needs to be reinstalled. Also
fix skins after reinstalling

Definition at line 77 of file migration_util.py.

00077 
00078 def installOrReinstallProduct(portal, product_name, out, hidden=False):
00079     """Installs a product
00080 
00081     If product is already installed test if it needs to be reinstalled. Also
00082     fix skins after reinstalling
00083     """
00084     qi = getToolByName(portal, 'portal_quickinstaller')
00085     if not qi.isProductInstalled(product_name):
00086         qi.installProduct(product_name, hidden=hidden)
00087         # Refresh skins
00088         if getattr(aq_base(portal), '_v_skindata', None) is not None:
00089             portal._v_skindata = None
00090         if getattr(aq_base(portal), 'setupCurrentSkin', None) is not None:
00091             portal.setupCurrentSkin()
00092         out.append('Installed %s.' % product_name)
00093     else:
00094         info = qi._getOb(product_name)
00095         installed_version = info.getInstalledVersion()
00096         product_version = qi.getProductVersion(product_name)
00097         if installed_version != product_version:
00098             qi.reinstallProducts([product_name])
00099             out.append('%s is out of date (installed: %s/ filesystem: %s), '\
00100                 'reinstalled.' % (product_name, installed_version, product_version))
00101         else:
00102             out.append('%s already installed.' % product_name)
00103 

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFPlone.migrations.migration_util.loadMigrationProfile (   portal,
  profile,
  steps = _marker 
)

Definition at line 104 of file migration_util.py.

00104 
00105 def loadMigrationProfile(portal, profile, steps=_marker):
00106     tool = getToolByName(portal, "portal_setup")
00107     if steps is _marker:
00108         tool.runAllImportStepsFromProfile(profile, purge_old=False)
00109     else:
00110         for step in steps:
00111             tool.runImportStepFromProfile(profile,
00112                                           step,
00113                                           run_dependencies=False,
00114                                           purge_old=False)

Here is the call graph for this function:

Here is the caller graph for this function:

def CMFPlone.migrations.migration_util.safeEditProperty (   obj,
  key,
  value,
  data_type = 'string' 
)
An add or edit function, surprisingly useful :) 

Definition at line 12 of file migration_util.py.

00012 
00013 def safeEditProperty(obj, key, value, data_type='string'):
00014     """ An add or edit function, surprisingly useful :) """
00015     if obj.hasProperty(key):
00016         obj._updateProperty(key, value)
00017     else:
00018         obj._setProperty(key, value, data_type)

Here is the caller graph for this function:

Definition at line 19 of file migration_util.py.

00019 
00020 def safeGetMemberDataTool(portal):
00021     memberdata = getToolByName(portal, 'portal_memberdata', None)
00022     if memberdata is not None:
00023         if memberdata.__class__ == MemberDataTool or \
00024                 memberdata.__class__ == PASMemberDataTool:
00025             return memberdata

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 41 of file migration_util.py.

00041 
00042 def saveCloneActions(actionprovider):
00043     try:
00044         return True, actionprovider._cloneActions()
00045     except AttributeError:
00046         # Stumbled across ancient dictionary actions
00047         if not hasattr(aq_base(actionprovider), '_convertActions'):
00048             return False, ('Can\'t convert actions of %s! Jumping to next action.' % actionprovider.getId(), logging.ERROR)
00049         else:
00050             actionprovider._convertActions()
00051             return True, actionprovider._cloneActions()

def CMFPlone.migrations.migration_util.testSkinLayer (   skinsTool,
  layer 
)
Make sure a skin layer exists

Definition at line 52 of file migration_util.py.

00052 
00053 def testSkinLayer(skinsTool, layer):
00054     """Make sure a skin layer exists"""
00055     # code adapted from CMFCore.SkinsContainer.getSkinByPath
00056     ob = aq_base(skinsTool)
00057     for name in layer.strip().split('/'):
00058         if not name:
00059             continue
00060         if name.startswith('_'):
00061             return 0
00062         ob = getattr(ob, name, None)
00063         if ob is None:
00064             return 0
00065     return 1

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 10 of file migration_util.py.