Back to index

plone3  3.1.7
Classes | Functions | Variables
GenericSetup.tool Namespace Reference

Classes

class  SetupTool

Functions

def exportStepRegistries
def importToolset
def exportToolset
def addSetupTool

Variables

string IMPORT_STEPS_XML = 'import_steps.xml'
string EXPORT_STEPS_XML = 'export_steps.xml'
string TOOLSET_XML = 'toolset.xml'
string _PLAINTEXT_DIFF_HEADER
string _TOOL_ID = 'setup_tool'
tuple addSetupToolForm = PageTemplateFile('toolAdd.zpt', _wwwdir)

Function Documentation

def GenericSetup.tool.addSetupTool (   dispatcher,
  RESPONSE 
)

Definition at line 1265 of file tool.py.

01265 
01266 def addSetupTool(dispatcher, RESPONSE):
01267     """
01268     """
01269     dispatcher._setObject(_TOOL_ID, SetupTool(_TOOL_ID))
01270 
01271     RESPONSE.redirect('%s/manage_main' % dispatcher.absolute_url())
Built-in handler for exporting import / export step registries.

Definition at line 68 of file tool.py.

00068 
00069 def exportStepRegistries(context):
00070 
00071     """ Built-in handler for exporting import / export step registries.
00072     """
00073     setup_tool = context.getSetupTool()
00074     logger = context.getLogger('registries')
00075 
00076     import_step_registry = setup_tool.getImportStepRegistry()
00077     if len(import_step_registry.listSteps()) > 0:
00078         import_steps_xml = import_step_registry.generateXML()
00079         context.writeDataFile('import_steps.xml', import_steps_xml, 'text/xml')
00080         logger.info('Local import steps exported.')
00081     else:
00082         logger.debug('No local import steps.')
00083 
00084     export_step_registry = setup_tool.getExportStepRegistry()
00085     if len(export_step_registry.listSteps()) > 0:
00086         export_steps_xml = export_step_registry.generateXML()
00087         context.writeDataFile('export_steps.xml', export_steps_xml, 'text/xml')
00088         logger.info('Local export steps exported.')
00089     else:
00090         logger.debug('No local export steps.')

Export required / forbidden tools to XML file.

Definition at line 147 of file tool.py.

00147 
00148 def exportToolset(context):
00149 
00150     """ Export required / forbidden tools to XML file.
00151     """
00152     setup_tool = context.getSetupTool()
00153     toolset = setup_tool.getToolsetRegistry()
00154     logger = context.getLogger('toolset')
00155 
00156     xml = toolset.generateXML()
00157     context.writeDataFile(TOOLSET_XML, xml, 'text/xml')
00158 
00159     logger.info('Toolset exported.')
00160 

Here is the caller graph for this function:

Import required / forbidden tools from XML file.

Definition at line 91 of file tool.py.

00091 
00092 def importToolset(context):
00093 
00094     """ Import required / forbidden tools from XML file.
00095     """
00096     site = context.getSite()
00097     encoding = context.getEncoding()
00098     logger = context.getLogger('toolset')
00099 
00100     xml = context.readDataFile(TOOLSET_XML)
00101     if xml is None:
00102         logger.debug('Nothing to import.')
00103         return
00104 
00105     setup_tool = context.getSetupTool()
00106     toolset = setup_tool.getToolsetRegistry()
00107 
00108     toolset.parseXML(xml, encoding)
00109 
00110     existing_ids = site.objectIds()
00111     existing_values = site.objectValues()
00112 
00113     for tool_id in toolset.listForbiddenTools():
00114 
00115         if tool_id in existing_ids:
00116             site._delObject(tool_id)
00117 
00118     for info in toolset.listRequiredToolInfo():
00119 
00120         tool_id = str(info['id'])
00121         tool_class = _resolveDottedName(info['class'])
00122 
00123         existing = getattr(aq_base(site), tool_id, None)
00124         # Don't even initialize the tool again, if it already exists.
00125         if existing is None:
00126             try:
00127                 new_tool = tool_class()
00128             except TypeError:
00129                 new_tool = tool_class(tool_id)
00130             else:
00131                 try:
00132                     new_tool._setId(tool_id)
00133                 except (ConflictError, KeyboardInterrupt):
00134                     raise
00135                 except:
00136                     # XXX: ImmutableId raises result of calling MessageDialog
00137                     pass
00138 
00139             site._setObject(tool_id, new_tool)
00140         else:
00141             unwrapped = aq_base(existing)
00142             if not isinstance(unwrapped, tool_class):
00143                 site._delObject(tool_id)
00144                 site._setObject(tool_id, tool_class())
00145 
00146     logger.info('Toolset imported.')

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Initial value:
00001 """\
00002 Comparing configurations: '%s' and '%s'
00003 
00004 %s"""

Definition at line 1256 of file tool.py.

string GenericSetup.tool._TOOL_ID = 'setup_tool'

Definition at line 1261 of file tool.py.

tuple GenericSetup.tool.addSetupToolForm = PageTemplateFile('toolAdd.zpt', _wwwdir)

Definition at line 1263 of file tool.py.

string GenericSetup.tool.EXPORT_STEPS_XML = 'export_steps.xml'

Definition at line 65 of file tool.py.

string GenericSetup.tool.IMPORT_STEPS_XML = 'import_steps.xml'

Definition at line 64 of file tool.py.

string GenericSetup.tool.TOOLSET_XML = 'toolset.xml'

Definition at line 66 of file tool.py.