Back to index

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

List of all members.

Public Member Functions

def __init__
def getEncoding
def getImportContextID
def getBaselineContextID
def setImportContext
def setBaselineContext
def applyContextById
def applyContext
def getImportStepRegistry
def getExportStepRegistry
def getExportStep
def listExportSteps
def getImportStep
def getSortedImportSteps
def getImportStepMetadata
def getExportStepMetadata
def getToolsetRegistry
def runImportStepFromProfile
def runImportStep
def runAllImportStepsFromProfile
def runAllImportSteps
def runExportStep
def runAllExportSteps
def createSnapshot
def compareConfigurations
def markupComparison
def manage_updateToolProperties
def manage_importSelectedSteps
def manage_importAllSteps
def manage_importExtensions
def manage_importTarball
def manage_exportSelectedSteps
def manage_exportAllSteps
def listSnapshotInfo
def listProfileInfo
def listContextInfos
def getProfileImportDate
def manage_createSnapshot
def manage_downloadDiff
def manage_compareConfigurations
def manage_deleteImportSteps
def manage_deleteExportSteps
def getLastVersionForProfile
def setLastVersionForProfile
def getVersionForProfile
def profileExists
def getProfileInfo
def getDependenciesForProfile
def listProfilesWithUpgrades
def listUpgrades
def manage_doUpgrades
def getProfileDependencyChain

Public Attributes

 id

Static Public Attributes

string meta_type = 'Generic Setup Tool'
tuple security = ClassSecurityInfo()
tuple manage_options
tuple manage_tool = PageTemplateFile('sutProperties', _wwwdir)
tuple manage_importSteps = PageTemplateFile('sutImportSteps', _wwwdir)
tuple manage_exportSteps = PageTemplateFile('sutExportSteps', _wwwdir)
tuple manage_upgrades = PageTemplateFile('setup_upgrades', _wwwdir)
tuple upgradeStepMacro = PageTemplateFile('upgradeStep', _wwwdir)
tuple manage_snapshots = PageTemplateFile('sutSnapshots', _wwwdir)
tuple manage_showDiff = PageTemplateFile('sutCompare', _wwwdir)
tuple manage_stepRegistry = PageTemplateFile('sutManage', _wwwdir)

Private Member Functions

def _massageUpgradeInfo
def _getImportContext
def _updateImportStepsRegistry
def _updateExportStepsRegistry
def _doRunImportStep
def _doRunExportSteps
def _runImportStepsFromContext
def _mangleTimestampName
def _createReport

Private Attributes

 _import_registry
 _export_registry
 _toolset_registry
 _import_context_id
 _baseline_context_id
 _p_changed
 _profile_upgrade_versions

Static Private Attributes

string _baseline_context_id = ''
string _import_context_id = ''
dictionary _profile_upgrade_versions = {}

Detailed Description

Profile-based site configuration manager.

Definition at line 161 of file tool.py.


Constructor & Destructor Documentation

def GenericSetup.tool.SetupTool.__init__ (   self,
  id 
)

Definition at line 178 of file tool.py.

00178 
00179     def __init__(self, id):
00180         self.id = str(id)
00181         self._import_registry = ImportStepRegistry()
00182         self._export_registry = ExportStepRegistry()
00183         self._toolset_registry = ToolsetRegistry()


Member Function Documentation

def GenericSetup.tool.SetupTool._createReport (   self,
  name,
  steps,
  messages 
) [private]
Record the results of a run.

Definition at line 1225 of file tool.py.

01225 
01226     def _createReport(self, name, steps, messages):
01227 
01228         """ Record the results of a run.
01229         """
01230         lines = []
01231         # Create report
01232         for step in steps:
01233             lines.append('=' * 65)
01234             lines.append('Step: %s' % step)
01235             lines.append('=' * 65)
01236             msg = messages[step]
01237             lines.extend(msg.split('\n'))
01238             lines.append('')
01239 
01240         report = '\n'.join(lines)
01241         if isinstance(report, unicode):
01242             report = report.encode('latin-1')
01243 
01244         # BBB: ObjectManager won't allow unicode IDS
01245         if isinstance(name, unicode):
01246             name = name.encode('UTF-8')
01247 
01248         file = File(id=name,
01249                     title='',
01250                     file=report,
01251                     content_type='text/plain'
01252                    )
01253         self._setObject(name, file)
01254 
01255 InitializeClass(SetupTool)

Here is the call graph for this function:

Here is the caller graph for this function:

def GenericSetup.tool.SetupTool._doRunExportSteps (   self,
  steps 
) [private]
See ISetupTool.

Definition at line 1096 of file tool.py.

01096 
01097     def _doRunExportSteps(self, steps):
01098 
01099         """ See ISetupTool.
01100         """
01101         context = TarballExportContext(self)
01102         messages = {}
01103         marker = object()
01104 
01105         for step_id in steps:
01106 
01107             handler = self.getExportStep(step_id, marker)
01108 
01109             if handler is marker:
01110                 raise ValueError('Invalid export step: %s' % step_id)
01111 
01112             if handler is None:
01113                 msg = 'Step %s has an invalid import handler' % step_id
01114                 logger = logging.getLogger('GenericSetup')
01115                 logger.error(msg)
01116                 messages[step_id] = msg
01117             else:
01118                 messages[step_id] = handler(context)
01119 
01120         return { 'steps' : steps
01121                , 'messages' : messages
01122                , 'tarball' : context.getArchive()
01123                , 'filename' : context.getArchiveFilename()
01124                }
01125 

Here is the call graph for this function:

Here is the caller graph for this function:

def GenericSetup.tool.SetupTool._doRunImportStep (   self,
  step_id,
  context 
) [private]
Run a single import step, using a pre-built context.

Definition at line 1075 of file tool.py.

01075 
01076     def _doRunImportStep(self, step_id, context):
01077 
01078         """ Run a single import step, using a pre-built context.
01079         """
01080         __traceback_info__ = step_id
01081         marker = object()
01082 
01083         handler = self.getImportStep(step_id)
01084 
01085         if handler is marker:
01086             raise ValueError('Invalid import step: %s' % step_id)
01087 
01088         if handler is None:
01089             msg = 'Step %s has an invalid import handler' % step_id
01090             logger = logging.getLogger('GenericSetup')
01091             logger.error(msg)
01092             return 'ERROR: ' + msg
01093 
01094         return handler(context)

Here is the call graph for this function:

Here is the caller graph for this function:

def GenericSetup.tool.SetupTool._getImportContext (   self,
  context_id,
  should_purge = None,
  archive = None 
) [private]
Crack ID and generate appropriate import context.

Definition at line 983 of file tool.py.

00983 
00984     def _getImportContext(self, context_id, should_purge=None, archive=None):
00985 
00986         """ Crack ID and generate appropriate import context.
00987         """
00988         encoding = self.getEncoding()
00989 
00990         if context_id is not None:
00991             if context_id.startswith('profile-'):
00992                 context_id = context_id[len('profile-'):]
00993                 info = _profile_registry.getProfileInfo(context_id)
00994 
00995                 if info.get('product'):
00996                     path = os.path.join(_getProductPath(info['product'])
00997                                        , info['path'])
00998                 else:
00999                     path = info['path']
01000                 if should_purge is None:
01001                     should_purge = (info.get('type') != EXTENSION)
01002                 return DirectoryImportContext(self, path, should_purge, encoding)
01003 
01004             elif context_id.startswith('snapshot-'):
01005                 context_id = context_id[len('snapshot-'):]
01006                 if should_purge is None:
01007                     should_purge = True
01008                 return SnapshotImportContext(self, context_id, should_purge, encoding)
01009 
01010         if archive is not None:
01011             return TarballImportContext(tool=self,
01012                                        archive_bits=archive,
01013                                        encoding='UTF8',
01014                                        should_purge=should_purge,
01015                                       )
01016 
01017         raise KeyError, 'Unknown context "%s"' % context_id

Here is the call graph for this function:

Here is the caller graph for this function:

def GenericSetup.tool.SetupTool._mangleTimestampName (   self,
  prefix,
  ext = None 
) [private]
Create a mangled ID using a timestamp.

Definition at line 1209 of file tool.py.

01209 
01210     def _mangleTimestampName(self, prefix, ext=None):
01211 
01212         """ Create a mangled ID using a timestamp.
01213         """
01214         timestamp = time.gmtime()
01215         items = (prefix,) + timestamp[:6]
01216 
01217         if ext is None:
01218             fmt = '%s-%4d%02d%02d%02d%02d%02d'
01219         else:
01220             fmt = '%s-%4d%02d%02d%02d%02d%02d.%s'
01221             items += (ext,)
01222 
01223         return fmt % items

Here is the caller graph for this function:

def GenericSetup.tool.SetupTool._massageUpgradeInfo (   self,
  info 
) [private]
Add a couple of data points to the upgrade info dictionary.

Definition at line 923 of file tool.py.

00923 
00924     def _massageUpgradeInfo(self, info):
00925         """Add a couple of data points to the upgrade info dictionary.
00926         """
00927         info = info.copy()
00928         info['haspath'] = info['source'] and info['dest']
00929         info['ssource'] = '.'.join(info['source'] or ('all',))
00930         info['sdest'] = '.'.join(info['dest'] or ('all',))
00931         return info

Here is the caller graph for this function:

def GenericSetup.tool.SetupTool._runImportStepsFromContext (   self,
  steps = None,
  purge_old = None,
  profile_id = None,
  archive = None,
  ignore_dependencies = False,
  seen = None 
) [private]

Definition at line 1151 of file tool.py.

01151 
01152                                    seen=None):
01153 
01154         if profile_id is not None and not ignore_dependencies:
01155             try: 
01156                 chain = self.getProfileDependencyChain( profile_id )
01157             except KeyError, e:
01158                 logger = logging.getLogger('GenericSetup')
01159                 logger.error('Unknown step in dependency chain: %s' % str(e))
01160                 raise
01161         else:
01162             chain = [ profile_id ]
01163             if seen is None:
01164                 seen=set()
01165             seen.add( profile_id )
01166 
01167         
01168         results = []
01169 
01170         detect_steps = steps is None
01171 
01172         for profile_id in chain:
01173             context = self._getImportContext(profile_id, purge_old, archive)
01174             self.applyContext(context)
01175 
01176             if detect_steps:
01177                 steps = self.getSortedImportSteps()
01178 
01179             messages = {}
01180 
01181             event.notify(BeforeProfileImportEvent(self, profile_id, steps, True))
01182             for step in steps:
01183                 message = self._doRunImportStep(step, context)
01184                 message_list = filter(None, [message])
01185                 message_list.extend( ['%s: %s' % x[1:]
01186                                       for x in context.listNotes()] )
01187                 messages[step] = '\n'.join(message_list)
01188                 context.clearNotes()
01189 
01190             event.notify(ProfileImportedEvent(self, profile_id, steps, True))
01191 
01192             results.append({'steps' : steps, 'messages' : messages })
01193 
01194         data = { 'steps' : [], 'messages' : {}}
01195         for result in results:
01196             for step in result['steps']:
01197                 if step not in data['steps']:
01198                     data['steps'].append(step)
01199 
01200             for (step, msg) in result['messages'].items():
01201                 if step in data['messages']:
01202                     data['messages'][step]+="\n"+msg
01203                 else:
01204                     data['messages'][step]=msg
01205         data['steps'] = list(data['steps'])
01206 
01207         return data

Here is the call graph for this function:

Here is the caller graph for this function:

def GenericSetup.tool.SetupTool._updateExportStepsRegistry (   self,
  context,
  encoding 
) [private]
Update our export steps registry from our profile.

Definition at line 1049 of file tool.py.

01049 
01050     def _updateExportStepsRegistry(self, context, encoding):
01051 
01052         """ Update our export steps registry from our profile.
01053         """
01054         if context is None:
01055             context = self._getImportContext(self._import_context_id)
01056         xml = context.readDataFile(EXPORT_STEPS_XML)
01057         if xml is None:
01058             return
01059 
01060         info_list = self._export_registry.parseXML(xml, encoding)
01061 
01062         for step_info in info_list:
01063 
01064             id = step_info['id']
01065             handler = step_info['handler']
01066             title = step_info.get('title', id)
01067             description = ''.join(step_info.get('description', []))
01068 
01069             self._export_registry.registerStep(id=id,
01070                                                handler=handler,
01071                                                title=title,
01072                                                description=description,
01073                                               )

Here is the call graph for this function:

Here is the caller graph for this function:

def GenericSetup.tool.SetupTool._updateImportStepsRegistry (   self,
  context,
  encoding 
) [private]
Update our import steps registry from our profile.

Definition at line 1019 of file tool.py.

01019 
01020     def _updateImportStepsRegistry(self, context, encoding):
01021 
01022         """ Update our import steps registry from our profile.
01023         """
01024         if context is None:
01025             context = self._getImportContext(self._import_context_id)
01026         xml = context.readDataFile(IMPORT_STEPS_XML)
01027         if xml is None:
01028             return
01029 
01030         info_list = self._import_registry.parseXML(xml, encoding)
01031 
01032         for step_info in info_list:
01033 
01034             id = step_info['id']
01035             version = step_info['version']
01036             handler = step_info['handler']
01037             dependencies = tuple(step_info.get('dependencies', ()))
01038             title = step_info.get('title', id)
01039             description = ''.join(step_info.get('description', []))
01040 
01041             self._import_registry.registerStep(id=id,
01042                                                version=version,
01043                                                handler=handler,
01044                                                dependencies=dependencies,
01045                                                title=title,
01046                                                description=description,
01047                                               )

Here is the call graph for this function:

Here is the caller graph for this function:

def GenericSetup.tool.SetupTool.applyContext (   self,
  context,
  encoding = None 
)

Definition at line 245 of file tool.py.

00245 
00246     def applyContext(self, context, encoding=None):
00247         self._updateImportStepsRegistry(context, encoding)
00248         self._updateExportStepsRegistry(context, encoding)

Here is the call graph for this function:

Here is the caller graph for this function:

def GenericSetup.tool.SetupTool.applyContextById (   self,
  context_id,
  encoding = None 
)

Definition at line 239 of file tool.py.

00239 
00240     def applyContextById(self, context_id, encoding=None):
00241         context = self._getImportContext(context_id)
00242         self.applyContext(context, encoding)
00243 

Here is the call graph for this function:

def GenericSetup.tool.SetupTool.compareConfigurations (   self,
  lhs_context,
  rhs_context,
  missing_as_empty = False,
  ignore_blanks = False,
  skip = SKIPPED_FILES 
)
See ISetupTool.

Definition at line 462 of file tool.py.

00462 
00463                              ):
00464         """ See ISetupTool.
00465         """
00466         differ = ConfigDiff(lhs_context,
00467                             rhs_context,
00468                             missing_as_empty,
00469                             ignore_blanks,
00470                             skip,
00471                            )
00472 
00473         return differ.compare()

Here is the caller graph for this function:

def GenericSetup.tool.SetupTool.createSnapshot (   self,
  snapshot_id 
)
See ISetupTool.

Definition at line 429 of file tool.py.

00429 
00430     def createSnapshot(self, snapshot_id):
00431 
00432         """ See ISetupTool.
00433         """
00434         context = SnapshotExportContext(self, snapshot_id)
00435         messages = {}
00436         steps = self.listExportSteps()
00437 
00438         for step_id in steps:
00439 
00440             handler = self.getExportStep(step_id)
00441 
00442             if handler is None:
00443                 logger = logging.getLogger('GenericSetup')
00444                 logger.error('Step %s has an invalid handler' % step_id)
00445                 continue
00446 
00447             messages[step_id] = handler(context)
00448 
00449 
00450         return { 'steps' : steps
00451                , 'messages' : messages
00452                , 'url' : context.getSnapshotURL()
00453                , 'snapshot' : context.getSnapshotFolder()
00454                }

Here is the call graph for this function:

Here is the caller graph for this function:

See ISetupTool.

Definition at line 206 of file tool.py.

00206 
00207     def getBaselineContextID(self):
00208 
00209         """ See ISetupTool.
00210         """
00211         return self._baseline_context_id

Here is the caller graph for this function:

Definition at line 906 of file tool.py.

00906 
00907     def getDependenciesForProfile(self, profile_id):
00908         if profile_id.startswith("snapshot-"):
00909             return ()
00910 
00911         if not self.profileExists( profile_id ):
00912             raise KeyError, profile_id
00913         try:
00914             return self.getProfileInfo( profile_id ).get('dependencies', ())
00915         except KeyError:
00916             return ()
00917 

Here is the call graph for this function:

Here is the caller graph for this function:

See ISetupTool.

Definition at line 188 of file tool.py.

00188 
00189     def getEncoding(self):
00190 
00191         """ See ISetupTool.
00192         """
00193         return 'utf-8'

Here is the caller graph for this function:

def GenericSetup.tool.SetupTool.getExportStep (   self,
  step,
  default = None 
)
Simple wrapper to query both the global and local step registry.

Definition at line 264 of file tool.py.

00264 
00265     def getExportStep(self, step, default=None):
00266         """Simple wrapper to query both the global and local step registry."""
00267         res=_export_step_registry.getStep(step, default)
00268         if res is not default:
00269             return res
00270         return self._export_registry.getStep(step, default)

Here is the caller graph for this function:

def GenericSetup.tool.SetupTool.getExportStepMetadata (   self,
  step,
  default = None 
)
Simple wrapper to query both the global and local step registry.

Definition at line 302 of file tool.py.

00302 
00303     def getExportStepMetadata(self, step, default=None):
00304         """Simple wrapper to query both the global and local step registry."""
00305         res=self._export_registry.getStepMetadata(step, default)
00306         if res is not default:
00307             return res
00308         return _export_step_registry.getStepMetadata(step, default)

See ISetupTool.

Definition at line 257 of file tool.py.

00257 
00258     def getExportStepRegistry(self):
00259 
00260         """ See ISetupTool.
00261         """
00262         return self._export_registry

See ISetupTool.

Definition at line 195 of file tool.py.

00195 
00196     def getImportContextID(self):
00197 
00198         """ See ISetupTool.
00199         """
00200         warn('getImportContextId, and the very concept of a stateful '
00201              'active import context, is deprecated.  You can find the '
00202              'base profile that was applied using getBaselineContextID.',
00203              DeprecationWarning, stacklevel=2)
00204         return self._import_context_id

Here is the call graph for this function:

def GenericSetup.tool.SetupTool.getImportStep (   self,
  step,
  default = None 
)
Simple wrapper to query both the global and local step registry.

Definition at line 278 of file tool.py.

00278 
00279     def getImportStep(self, step, default=None):
00280         """Simple wrapper to query both the global and local step registry."""
00281         res=_import_step_registry.getStep(step, default)
00282         if res is not default:
00283             return res
00284         return self._import_registry.getStep(step, default)

Here is the caller graph for this function:

def GenericSetup.tool.SetupTool.getImportStepMetadata (   self,
  step,
  default = None 
)
Simple wrapper to query both the global and local step registry.

Definition at line 294 of file tool.py.

00294 
00295     def getImportStepMetadata(self, step, default=None):
00296         """Simple wrapper to query both the global and local step registry."""
00297         res=self._import_registry.getStepMetadata(step, default)
00298         if res is not default:
00299             return res
00300         return _import_step_registry.getStepMetadata(step, default)

Here is the caller graph for this function:

See ISetupTool.

Definition at line 250 of file tool.py.

00250 
00251     def getImportStepRegistry(self):
00252 
00253         """ See ISetupTool.
00254         """
00255         return self._import_registry

def GenericSetup.tool.SetupTool.getLastVersionForProfile (   self,
  profile_id 
)
Return the last upgraded version for the specified profile.

Definition at line 864 of file tool.py.

00864 
00865     def getLastVersionForProfile(self, profile_id):
00866         """Return the last upgraded version for the specified profile.
00867         """
00868         version = self._profile_upgrade_versions.get(profile_id, 'unknown')
00869         return version

Here is the caller graph for this function:

def GenericSetup.tool.SetupTool.getProfileDependencyChain (   self,
  profile_id,
  seen = None 
)

Definition at line 1127 of file tool.py.

01127 
01128     def getProfileDependencyChain(self, profile_id, seen=None):
01129         if seen is None:
01130             seen = set()
01131         elif profile_id in seen:
01132             return [] # cycle break
01133         seen.add( profile_id )
01134         chain = []
01135 
01136         dependencies = self.getDependenciesForProfile( profile_id )
01137         for dependency in dependencies:
01138             chain.extend(self.getProfileDependencyChain( dependency, seen ))
01139 
01140         chain.append(profile_id)
01141 
01142         return chain
01143 

Here is the call graph for this function:

Here is the caller graph for this function:

def GenericSetup.tool.SetupTool.getProfileImportDate (   self,
  profile_id 
)
See ISetupTool.

Definition at line 762 of file tool.py.

00762 
00763     def getProfileImportDate(self, profile_id):
00764         """ See ISetupTool.
00765         """
00766         prefix = ('import-all-%s-' % profile_id).replace(':', '_')
00767         candidates = [x for x in self.objectIds('File')
00768                         if x[:-18]==prefix and x.endswith('.log')]
00769         if len(candidates) == 0:
00770             return None
00771         candidates.sort()
00772         last = candidates[-1]
00773         stamp = last[-18:-4]
00774         return '%s-%s-%sT%s:%s:%sZ' % (stamp[0:4],
00775                                        stamp[4:6],
00776                                        stamp[6:8],
00777                                        stamp[8:10],
00778                                        stamp[10:12],
00779                                        stamp[12:14],
00780                                       )

Here is the call graph for this function:

def GenericSetup.tool.SetupTool.getProfileInfo (   self,
  profile_id 
)

Definition at line 898 of file tool.py.

00898 
00899     def getProfileInfo(self, profile_id):
00900         if profile_id.startswith("profile-"):
00901             profile_id = profile_id[len('profile-'):]
00902         elif profile_id.startswith("snapshot-"):
00903             profile_id = profile_id[len('snapshot-'):]
00904         return _profile_registry.getProfileInfo(profile_id)

Here is the caller graph for this function:

Definition at line 286 of file tool.py.

00286 
00287     def getSortedImportSteps(self):
00288         steps = _import_step_registry.listSteps() + \
00289                 self._import_registry.listSteps()
00290         step_infos = [ self.getImportStepMetadata(step)
00291                        for step in set(steps) ]
00292         return tuple(_computeTopologicalSort(step_infos))

Here is the call graph for this function:

Here is the caller graph for this function:

See ISetupTool.

Definition at line 310 of file tool.py.

00310 
00311     def getToolsetRegistry(self):
00312 
00313         """ See ISetupTool.
00314         """
00315         return self._toolset_registry

Here is the call graph for this function:

def GenericSetup.tool.SetupTool.getVersionForProfile (   self,
  profile_id 
)
Return the registered filesystem version for the specified
profile.

Definition at line 881 of file tool.py.

00881 
00882     def getVersionForProfile(self, profile_id):
00883         """Return the registered filesystem version for the specified
00884         profile.
00885         """
00886         return self.getProfileInfo( profile_id ).get('version', 'unknown')

Here is the call graph for this function:

List registered profiles and snapshots.

Definition at line 737 of file tool.py.

00737 
00738     def listContextInfos(self):
00739 
00740         """ List registered profiles and snapshots.
00741         """
00742         def readableType(x):
00743             if x is BASE:
00744                 return 'base'
00745             elif x is EXTENSION:
00746                 return 'extension'
00747             return 'unknown'
00748 
00749         s_infos = [{'id': 'snapshot-%s' % info['id'],
00750                      'title': info['title'],
00751                      'type': 'snapshot',
00752                    }
00753                     for info in self.listSnapshotInfo()]
00754         p_infos = [{'id': 'profile-%s' % info['id'],
00755                     'title': info['title'],
00756                     'type': readableType(info['type']),
00757                    }
00758                    for info in self.listProfileInfo()]
00759 
00760         return tuple(s_infos + p_infos)

Here is the call graph for this function:

Definition at line 272 of file tool.py.

00272 
00273     def listExportSteps(self):
00274         steps = _export_step_registry.listSteps() + \
00275                 self._export_registry.listSteps()
00276         return tuple(set(steps))

Here is the caller graph for this function:

Return a list of mappings describing registered profiles.
Base profile is listed first, extensions are sorted.

o Keys include:

  'id' -- profile ID

  'title' -- profile title or ID

  'description' -- description of the profile

  'path' -- path to the profile within its product

  'product' -- name of the registering product

Definition at line 709 of file tool.py.

00709 
00710     def listProfileInfo(self):
00711 
00712         """ Return a list of mappings describing registered profiles.
00713         Base profile is listed first, extensions are sorted.
00714 
00715         o Keys include:
00716 
00717           'id' -- profile ID
00718 
00719           'title' -- profile title or ID
00720 
00721           'description' -- description of the profile
00722 
00723           'path' -- path to the profile within its product
00724 
00725           'product' -- name of the registering product
00726         """
00727         base = []
00728         ext = []
00729         for info in _profile_registry.listProfileInfo():
00730             if info.get('type', BASE) == BASE:
00731                 base.append(info)
00732             else:
00733                 ext.append(info)
00734         ext.sort(lambda x, y: cmp(x['id'], y['id']))
00735         return base + ext

Here is the caller graph for this function:

Definition at line 919 of file tool.py.

Return a list of mappings describing available snapshots.

o Keys include:

  'id' -- snapshot ID

  'title' -- snapshot title or ID

  'url' -- URL of the snapshot folder

Definition at line 683 of file tool.py.

00683 
00684     def listSnapshotInfo(self):
00685 
00686         """ Return a list of mappings describing available snapshots.
00687 
00688         o Keys include:
00689 
00690           'id' -- snapshot ID
00691 
00692           'title' -- snapshot title or ID
00693 
00694           'url' -- URL of the snapshot folder
00695         """
00696         result = []
00697         snapshots = self._getOb('snapshots', None)
00698 
00699         if snapshots:
00700 
00701             for id, folder in snapshots.objectItems('Folder'):
00702 
00703                 result.append({ 'id' : id
00704                                , 'title' : folder.title_or_id()
00705                                , 'url' : folder.absolute_url()
00706                                })
00707         return result

Here is the call graph for this function:

Here is the caller graph for this function:

def GenericSetup.tool.SetupTool.listUpgrades (   self,
  profile_id,
  show_old = False 
)
Get the list of available upgrades.

Definition at line 933 of file tool.py.

00933 
00934     def listUpgrades(self, profile_id, show_old=False):
00935         """Get the list of available upgrades.
00936         """
00937         if show_old:
00938             source = None
00939         else:
00940             source = self.getLastVersionForProfile(profile_id)
00941         upgrades = listUpgradeSteps(self, profile_id, source)
00942         res = []
00943         for info in upgrades:
00944             if type(info) == list:
00945                 subset = []
00946                 for subinfo in info:
00947                     subset.append(self._massageUpgradeInfo(subinfo))
00948                 res.append(subset)
00949             else:
00950                 res.append(self._massageUpgradeInfo(info))
00951         return res

Here is the call graph for this function:

def GenericSetup.tool.SetupTool.manage_compareConfigurations (   self,
  lhs,
  rhs,
  missing_as_empty,
  ignore_blanks 
)
Crack request vars and call compareConfigurations.

Definition at line 825 of file tool.py.

00825 
00826                                     ):
00827         """ Crack request vars and call compareConfigurations.
00828         """
00829         lhs_context = self._getImportContext(lhs)
00830         rhs_context = self._getImportContext(rhs)
00831 
00832         return self.compareConfigurations(lhs_context,
00833                                           rhs_context,
00834                                           missing_as_empty,
00835                                           ignore_blanks,
00836                                          )

Here is the call graph for this function:

Here is the caller graph for this function:

def GenericSetup.tool.SetupTool.manage_createSnapshot (   self,
  RESPONSE,
  snapshot_id = None 
)
Create a snapshot with the given ID.

o If no ID is passed, generate one.

Definition at line 782 of file tool.py.

00782 
00783     def manage_createSnapshot(self, RESPONSE, snapshot_id=None):
00784 
00785         """ Create a snapshot with the given ID.
00786 
00787         o If no ID is passed, generate one.
00788         """
00789         if snapshot_id is None:
00790             snapshot_id = self._mangleTimestampName('snapshot')
00791 
00792         self.createSnapshot(snapshot_id)
00793 
00794         RESPONSE.redirect('%s/manage_snapshots?manage_tabs_message=%s'
00795                          % (self.absolute_url(), 'Snapshot+created.'))
00796         return ""

Here is the call graph for this function:

def GenericSetup.tool.SetupTool.manage_deleteExportSteps (   self,
  ids,
  request = None 
)

Definition at line 851 of file tool.py.

00851 
00852     def manage_deleteExportSteps(self, ids, request=None):
00853         if request is None:
00854             request = self.REQUEST
00855         for id in ids:
00856             self._export_registry.unregisterStep(id)
00857         self._p_changed=True
00858         url = self.absolute_url()
00859         request.RESPONSE.redirect("%s/manage_stepRegistry" % url)

Here is the call graph for this function:

def GenericSetup.tool.SetupTool.manage_deleteImportSteps (   self,
  ids,
  request = None 
)

Definition at line 841 of file tool.py.

00841 
00842     def manage_deleteImportSteps(self, ids, request=None):
00843         if request is None:
00844             request = self.REQUEST
00845         for id in ids:
00846             self._import_registry.unregisterStep(id)
00847         self._p_changed=True
00848         url = self.absolute_url()
00849         request.RESPONSE.redirect("%s/manage_stepRegistry" % url)

def GenericSetup.tool.SetupTool.manage_doUpgrades (   self,
  request = None 
)
Perform all selected upgrade steps.

Definition at line 953 of file tool.py.

00953 
00954     def manage_doUpgrades(self, request=None):
00955         """Perform all selected upgrade steps.
00956         """
00957         if request is None:
00958             request = self.REQUEST
00959         logger = logging.getLogger('GenericSetup')
00960         steps_to_run = request.form.get('upgrades', [])
00961         profile_id = request.get('profile_id', '')
00962         for step_id in steps_to_run:
00963             step = _upgrade_registry.getUpgradeStep(profile_id, step_id)
00964             if step is not None:
00965                 step.doStep(self)
00966                 msg = "Ran upgrade step %s for profile %s" % (step.title,
00967                                                               profile_id)
00968                 logger.log(logging.INFO, msg)
00969 
00970         # XXX should be a bit smarter about deciding when to up the
00971         #     profile version
00972         profile_info = _profile_registry.getProfileInfo(profile_id)
00973         version = profile_info.get('version', None)
00974         if version is not None:
00975             self.setLastVersionForProfile(profile_id, version)
00976 
00977         url = self.absolute_url()
00978         request.RESPONSE.redirect("%s/manage_upgrades?saved=%s" % (url, profile_id))

Here is the call graph for this function:

def GenericSetup.tool.SetupTool.manage_downloadDiff (   self,
  lhs,
  rhs,
  missing_as_empty,
  ignore_blanks,
  RESPONSE 
)
Crack request vars and call compareConfigurations.

o Return the result as a 'text/plain' stream, suitable for framing.

Definition at line 806 of file tool.py.

00806 
00807                            ):
00808         """ Crack request vars and call compareConfigurations.
00809 
00810         o Return the result as a 'text/plain' stream, suitable for framing.
00811         """
00812         comparison = self.manage_compareConfigurations(lhs,
00813                                                        rhs,
00814                                                        missing_as_empty,
00815                                                        ignore_blanks,
00816                                                       )
00817         RESPONSE.setHeader('Content-Type', 'text/plain')
00818         return _PLAINTEXT_DIFF_HEADER % (lhs, rhs, comparison)

Here is the call graph for this function:

def GenericSetup.tool.SetupTool.manage_exportAllSteps (   self,
  RESPONSE 
)
Export all steps.

Definition at line 663 of file tool.py.

00663 
00664     def manage_exportAllSteps(self, RESPONSE):
00665 
00666         """ Export all steps.
00667         """
00668         result = self.runAllExportSteps()
00669         RESPONSE.setHeader('Content-type', 'application/x-gzip')
00670         RESPONSE.setHeader('Content-disposition',
00671                            'attachment; filename=%s' % result['filename'])
00672         return result['tarball']

Here is the call graph for this function:

def GenericSetup.tool.SetupTool.manage_exportSelectedSteps (   self,
  ids,
  RESPONSE 
)
Export the steps selected by the user.

Definition at line 648 of file tool.py.

00648 
00649     def manage_exportSelectedSteps(self, ids, RESPONSE):
00650 
00651         """ Export the steps selected by the user.
00652         """
00653         if not ids:
00654             RESPONSE.redirect('%s/manage_exportSteps?manage_tabs_message=%s'
00655                              % (self.absolute_url(), 'No+steps+selected.'))
00656 
00657         result = self._doRunExportSteps(ids)
00658         RESPONSE.setHeader('Content-type', 'application/x-gzip')
00659         RESPONSE.setHeader('Content-disposition',
00660                            'attachment; filename=%s' % result['filename'])
00661         return result['tarball']

Here is the call graph for this function:

def GenericSetup.tool.SetupTool.manage_importAllSteps (   self,
  context_id = None 
)
Import all steps.

Definition at line 594 of file tool.py.

00594 
00595     def manage_importAllSteps(self, context_id=None):
00596 
00597         """ Import all steps.
00598         """
00599         if context_id is None:
00600             context_id = self.getBaselineContextID()
00601         result = self.runAllImportStepsFromProfile(context_id, purge_old=None)
00602 
00603         steps_run = 'Steps run: %s' % ', '.join(result['steps'])
00604 
00605         return self.manage_importSteps(manage_tabs_message=steps_run,
00606                                        messages=result['messages'])

Here is the call graph for this function:

def GenericSetup.tool.SetupTool.manage_importExtensions (   self,
  RESPONSE,
  profile_ids = () 
)
Import all steps for the selected extension profiles.

Definition at line 608 of file tool.py.

00608 
00609     def manage_importExtensions(self, RESPONSE, profile_ids=()):
00610 
00611         """ Import all steps for the selected extension profiles.
00612         """
00613         detail = {}
00614         if len(profile_ids) == 0:
00615             message = 'Please select one or more extension profiles.'
00616             RESPONSE.redirect('%s/manage_tool?manage_tabs_message=%s'
00617                                   % (self.absolute_url(), message))
00618         else:
00619             message = 'Imported profiles: %s' % ', '.join(profile_ids)
00620         
00621             for profile_id in profile_ids:
00622 
00623                 result = self.runAllImportStepsFromProfile(profile_id)
00624 
00625                 for k, v in result['messages'].items():
00626                     detail['%s:%s' % (profile_id, k)] = v
00627 
00628             return self.manage_importSteps(manage_tabs_message=message,
00629                                         messages=detail)

Here is the call graph for this function:

def GenericSetup.tool.SetupTool.manage_importSelectedSteps (   self,
  ids,
  run_dependencies,
  context_id = None 
)
Import the steps selected by the user.

Definition at line 567 of file tool.py.

00567 
00568     def manage_importSelectedSteps(self, ids, run_dependencies, context_id=None):
00569         """ Import the steps selected by the user.
00570         """
00571         messages = {}
00572         if not ids:
00573             summary = 'No steps selected.'
00574 
00575         else:
00576             if context_id is None:
00577                 context_id = self.getBaselineContextID()
00578             steps_run = []
00579             for step_id in ids:
00580                 result = self.runImportStepFromProfile(context_id,
00581                                                        step_id,
00582                                                        run_dependencies)
00583                 steps_run.extend(result['steps'])
00584                 messages.update(result['messages'])
00585 
00586             summary = 'Steps run: %s' % ', '.join(steps_run)
00587 
00588             name = self._mangleTimestampName('import-selected', 'log')
00589             self._createReport(name, result['steps'], result['messages'])
00590 
00591         return self.manage_importSteps(manage_tabs_message=summary,
00592                                        messages=messages)

Here is the call graph for this function:

def GenericSetup.tool.SetupTool.manage_importTarball (   self,
  tarball 
)
Import steps from the uploaded tarball.

Definition at line 631 of file tool.py.

00631 
00632     def manage_importTarball(self, tarball):
00633         """ Import steps from the uploaded tarball.
00634         """
00635         if getattr(tarball, 'read', None) is not None:
00636             tarball = tarball.read()
00637 
00638         result = self.runAllImportStepsFromProfile(None, True, archive=tarball)
00639 
00640         steps_run = 'Steps run: %s' % ', '.join(result['steps'])
00641 
00642         return self.manage_importSteps(manage_tabs_message=steps_run,
00643                                        messages=result['messages'])

Here is the call graph for this function:

def GenericSetup.tool.SetupTool.manage_updateToolProperties (   self,
  context_id,
  RESPONSE 
)
Update the tool's settings.

Definition at line 555 of file tool.py.

00555 
00556     def manage_updateToolProperties(self, context_id, RESPONSE):
00557         """ Update the tool's settings.
00558         """
00559         self.setBaselineContext(context_id)
00560 
00561         RESPONSE.redirect('%s/manage_tool?manage_tabs_message=%s'
00562                          % (self.absolute_url(), 'Properties+updated.'))

Here is the call graph for this function:

def GenericSetup.tool.SetupTool.markupComparison (   self,
  lines 
)
See ISetupTool.

Definition at line 475 of file tool.py.

00475 
00476     def markupComparison(self, lines):
00477 
00478         """ See ISetupTool.
00479         """
00480         result = []
00481 
00482         for line in lines.splitlines():
00483 
00484             if line.startswith('** '):
00485 
00486                 if line.find('File') > -1:
00487                     if line.find('replaced') > -1:
00488                         result.append(('file-to-dir', line))
00489                     elif line.find('added') > -1:
00490                         result.append(('file-added', line))
00491                     else:
00492                         result.append(('file-removed', line))
00493                 else:
00494                     if line.find('replaced') > -1:
00495                         result.append(('dir-to-file', line))
00496                     elif line.find('added') > -1:
00497                         result.append(('dir-added', line))
00498                     else:
00499                         result.append(('dir-removed', line))
00500 
00501             elif line.startswith('@@'):
00502                 result.append(('diff-range', line))
00503 
00504             elif line.startswith(' '):
00505                 result.append(('diff-context', line))
00506 
00507             elif line.startswith('+'):
00508                 result.append(('diff-added', line))
00509 
00510             elif line.startswith('-'):
00511                 result.append(('diff-removed', line))
00512 
00513             elif line == '\ No newline at end of file':
00514                 result.append(('diff-context', line))
00515 
00516             else:
00517                 result.append(('diff-header', line))
00518 
00519         return '<pre>\n%s\n</pre>' % (
00520             '\n'.join([('<span class="%s">%s</span>' % (cl, escape(l)))
00521                                   for cl, l in result]))

def GenericSetup.tool.SetupTool.profileExists (   self,
  profile_id 
)
Check if a profile exists.

Definition at line 888 of file tool.py.

00888 
00889     def profileExists(self, profile_id):
00890         """Check if a profile exists."""
00891         try:
00892             self.getProfileInfo( profile_id )
00893         except KeyError:
00894             return False
00895         else:
00896             return True

Here is the call graph for this function:

Here is the caller graph for this function:

See ISetupTool.

Definition at line 422 of file tool.py.

00422 
00423     def runAllExportSteps(self):
00424 
00425         """ See ISetupTool.
00426         """
00427         return self._doRunExportSteps(self.listExportSteps())

Here is the call graph for this function:

Here is the caller graph for this function:

def GenericSetup.tool.SetupTool.runAllImportSteps (   self,
  purge_old = None 
)
See ISetupTool.

Definition at line 403 of file tool.py.

00403 
00404     def runAllImportSteps(self, purge_old=None):
00405 
00406         """ See ISetupTool.
00407         """
00408         warn('The runAllImportSteps method is deprecated.  Please use '
00409              'runAllImportStepsFromProfile instead.',
00410              DeprecationWarning, stacklevel=2)
00411         context_id = self._import_context_id
00412         return self.runAllImportStepsFromProfile(self._import_context_id,
00413                                                  purge_old)

Here is the call graph for this function:

def GenericSetup.tool.SetupTool.runAllImportStepsFromProfile (   self,
  profile_id,
  purge_old = None,
  ignore_dependencies = False,
  archive = None 
)
See ISetupTool.

Definition at line 379 of file tool.py.

00379 
00380                                      archive=None):
00381 
00382         """ See ISetupTool.
00383         """
00384         __traceback_info__ = profile_id
00385 
00386         old_context = self._import_context_id
00387 
00388         result = self._runImportStepsFromContext(purge_old=purge_old,
00389                                                  profile_id=profile_id,
00390                                                  archive=archive,
00391                                                  ignore_dependencies=ignore_dependencies)
00392         if profile_id is None:
00393             prefix = 'import-all-from-tar'
00394         else:
00395             prefix = 'import-all-%s' % profile_id.replace(':', '_')
00396         name = self._mangleTimestampName(prefix, 'log')
00397         self._createReport(name, result['steps'], result['messages'])
00398 
00399         self._import_context_id = old_context
00400 
00401         return result

Here is the call graph for this function:

Here is the caller graph for this function:

def GenericSetup.tool.SetupTool.runExportStep (   self,
  step_id 
)
See ISetupTool.

Definition at line 415 of file tool.py.

00415 
00416     def runExportStep(self, step_id):
00417 
00418         """ See ISetupTool.
00419         """
00420         return self._doRunExportSteps([step_id])

Here is the call graph for this function:

def GenericSetup.tool.SetupTool.runImportStep (   self,
  step_id,
  run_dependencies = True,
  purge_old = None 
)
See ISetupTool.

Definition at line 361 of file tool.py.

00361 
00362     def runImportStep(self, step_id, run_dependencies=True, purge_old=None):
00363 
00364         """ See ISetupTool.
00365         """
00366         warn('The runImportStep method is deprecated.  Please use '
00367              'runImportStepFromProfile instead.',
00368              DeprecationWarning, stacklevel=2)
00369         return self.runImportStepFromProfile(self._import_context_id,
00370                                              step_id,
00371                                              run_dependencies,
00372                                              purge_old,
00373                                              )

Here is the call graph for this function:

def GenericSetup.tool.SetupTool.runImportStepFromProfile (   self,
  profile_id,
  step_id,
  run_dependencies = True,
  purge_old = None 
)
See ISetupTool.

Definition at line 318 of file tool.py.

00318 
00319                                  run_dependencies=True, purge_old=None):
00320         """ See ISetupTool.
00321         """
00322         old_context = self._import_context_id
00323         context = self._getImportContext(profile_id, purge_old)
00324 
00325         self.applyContext(context)
00326 
00327         info = self.getImportStepMetadata(step_id)
00328 
00329         if info is None:
00330             self._import_context_id = old_context
00331             raise ValueError, 'No such import step: %s' % step_id
00332 
00333         dependencies = info.get('dependencies', ())
00334 
00335         messages = {}
00336         steps = []
00337 
00338         if run_dependencies:
00339             for dependency in dependencies:
00340                 if dependency not in steps:
00341                     steps.append(dependency)
00342         steps.append (step_id)
00343 
00344         full_import=(set(steps)==set(self.getSortedImportSteps()))
00345         event.notify(BeforeProfileImportEvent(self, profile_id, steps, full_import))
00346 
00347         for step in steps:
00348             message = self._doRunImportStep(step, context)
00349             messages[step] = message or ''
00350 
00351         message_list = filter(None, [message])
00352         message_list.extend( ['%s: %s' % x[1:] for x in context.listNotes()] )
00353         messages[step_id] = '\n'.join(message_list)
00354 
00355         self._import_context_id = old_context
00356 
00357         event.notify(ProfileImportedEvent(self, profile_id, steps, full_import))
00358 
00359         return { 'steps' : steps, 'messages' : messages }

Here is the call graph for this function:

Here is the caller graph for this function:

def GenericSetup.tool.SetupTool.setBaselineContext (   self,
  context_id,
  encoding = None 
)
See ISetupTool.

Definition at line 231 of file tool.py.

00231 
00232     def setBaselineContext(self, context_id, encoding=None):
00233         """ See ISetupTool.
00234         """
00235         self._baseline_context_id = context_id
00236         self.applyContextById(context_id, encoding)
00237 

Here is the caller graph for this function:

def GenericSetup.tool.SetupTool.setImportContext (   self,
  context_id,
  encoding = None 
)
See ISetupTool.

Definition at line 213 of file tool.py.

00213 
00214     def setImportContext(self, context_id, encoding=None):
00215         """ See ISetupTool.
00216         """
00217         warn('setImportContext is deprecated.  Use setBaselineContext to '
00218              'specify the baseline context, and/or runImportStepFromProfile '
00219              'to run the steps from a specific import context.',
00220              DeprecationWarning, stacklevel=2)
00221         self._import_context_id = context_id
00222 
00223         context_type = BASE  # snapshots are always baseline contexts
00224         if context_id.startswith('profile-'):
00225             profile_info = _profile_registry.getProfileInfo(context_id[8:])
00226             context_type = profile_info['type']
00227 
00228         if context_type == BASE:
00229             self.setBaselineContext(context_id, encoding)

Here is the call graph for this function:

def GenericSetup.tool.SetupTool.setLastVersionForProfile (   self,
  profile_id,
  version 
)
Set the last upgraded version for the specified profile.

Definition at line 871 of file tool.py.

00871 
00872     def setLastVersionForProfile(self, profile_id, version):
00873         """Set the last upgraded version for the specified profile.
00874         """
00875         if isinstance(version, basestring):
00876             version = tuple(version.split('.'))
00877         prof_versions = self._profile_upgrade_versions.copy()
00878         prof_versions[profile_id] = version
00879         self._profile_upgrade_versions = prof_versions

Here is the caller graph for this function:


Member Data Documentation

string GenericSetup.tool.SetupTool._baseline_context_id = '' [static, private]

Definition at line 170 of file tool.py.

Definition at line 234 of file tool.py.

Definition at line 181 of file tool.py.

string GenericSetup.tool.SetupTool._import_context_id = '' [static, private]

Definition at line 172 of file tool.py.

Definition at line 220 of file tool.py.

Definition at line 180 of file tool.py.

Definition at line 846 of file tool.py.

dictionary GenericSetup.tool.SetupTool._profile_upgrade_versions = {} [static, private]

Definition at line 174 of file tool.py.

Definition at line 878 of file tool.py.

Definition at line 182 of file tool.py.

Definition at line 179 of file tool.py.

tuple GenericSetup.tool.SetupTool.manage_exportSteps = PageTemplateFile('sutExportSteps', _wwwdir) [static]

Definition at line 645 of file tool.py.

tuple GenericSetup.tool.SetupTool.manage_importSteps = PageTemplateFile('sutImportSteps', _wwwdir) [static]

Definition at line 564 of file tool.py.

Initial value:
(Folder.manage_options[:1]
                    + ({'label' : 'Profiles',
                        'action' : 'manage_tool'
                       },
                       {'label' : 'Import',
                        'action' : 'manage_importSteps'
                       },
                       {'label' : 'Export',
                        'action' : 'manage_exportSteps'
                       },
                       {'label' : 'Upgrades',
                        'action' : 'manage_upgrades'
                        },
                       {'label' : 'Snapshots',
                        'action' : 'manage_snapshots'
                       },
                       {'label' : 'Comparison',
                        'action' : 'manage_showDiff'
                       },
                       {'label' : 'Manage',
                        'action' : 'manage_stepRegistry'
                       },
                      )
                    + Folder.manage_options[3:] # skip "View", "Properties"
                     )

Definition at line 525 of file tool.py.

tuple GenericSetup.tool.SetupTool.manage_showDiff = PageTemplateFile('sutCompare', _wwwdir) [static]

Definition at line 798 of file tool.py.

tuple GenericSetup.tool.SetupTool.manage_snapshots = PageTemplateFile('sutSnapshots', _wwwdir) [static]

Definition at line 680 of file tool.py.

tuple GenericSetup.tool.SetupTool.manage_stepRegistry = PageTemplateFile('sutManage', _wwwdir) [static]

Definition at line 838 of file tool.py.

tuple GenericSetup.tool.SetupTool.manage_tool = PageTemplateFile('sutProperties', _wwwdir) [static]

Definition at line 552 of file tool.py.

tuple GenericSetup.tool.SetupTool.manage_upgrades = PageTemplateFile('setup_upgrades', _wwwdir) [static]

Definition at line 674 of file tool.py.

string GenericSetup.tool.SetupTool.meta_type = 'Generic Setup Tool' [static]

Definition at line 168 of file tool.py.

tuple GenericSetup.tool.SetupTool.security = ClassSecurityInfo() [static]

Definition at line 176 of file tool.py.

tuple GenericSetup.tool.SetupTool.upgradeStepMacro = PageTemplateFile('upgradeStep', _wwwdir) [static]

Definition at line 677 of file tool.py.


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