[Checkins] SVN: Products.GenericSetup/trunk/Products/GenericSetup/ Add a ZMI interface to find and remove invalid steps from the persistent registries.

Wichert Akkerman wichert at wiggy.net
Fri Dec 28 06:01:24 EST 2007


Log message for revision 82476:
  Add a ZMI interface to find and remove invalid steps from the persistent registries.

Changed:
  U   Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt
  U   Products.GenericSetup/trunk/Products/GenericSetup/browser/configure.zcml
  A   Products.GenericSetup/trunk/Products/GenericSetup/browser/manage.py
  U   Products.GenericSetup/trunk/Products/GenericSetup/tool.py
  A   Products.GenericSetup/trunk/Products/GenericSetup/www/sutManage.zpt

-=-
Modified: Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt	2007-12-28 10:34:52 UTC (rev 82475)
+++ Products.GenericSetup/trunk/Products/GenericSetup/CHANGES.txt	2007-12-28 11:01:24 UTC (rev 82476)
@@ -2,6 +2,9 @@
 
   GenericSetup 1.4.0 (unreleased)
 
+    - Add a ZMI interface to find and remove invalid steps from the
+      persistent registries.
+
     - All GenericSetup import and export steps are now registered globally.
 
     - Remove duplicated test (https://bugs.launchpad.net/zope-cmf/+bug/174910)

Modified: Products.GenericSetup/trunk/Products/GenericSetup/browser/configure.zcml
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/browser/configure.zcml	2007-12-28 10:34:52 UTC (rev 82475)
+++ Products.GenericSetup/trunk/Products/GenericSetup/browser/configure.zcml	2007-12-28 11:01:24 UTC (rev 82476)
@@ -18,4 +18,18 @@
       permission="five.ManageSite"
       />
 
+  <browser:page
+      for="..interfaces.ISetupTool"
+      name="manage_importsteps"
+      class=".manage.ImportStepsView"
+      permission="five.ManageSite"
+      />
+
+  <browser:page
+      for="..interfaces.ISetupTool"
+      name="manage_exportsteps"
+      class=".manage.ExportStepsView"
+      permission="five.ManageSite"
+      />
+
 </configure>

Added: Products.GenericSetup/trunk/Products/GenericSetup/browser/manage.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/browser/manage.py	                        (rev 0)
+++ Products.GenericSetup/trunk/Products/GenericSetup/browser/manage.py	2007-12-28 11:01:24 UTC (rev 82476)
@@ -0,0 +1,33 @@
+from Products.Five import BrowserView
+from Products.GenericSetup.registry import _import_step_registry
+from Products.GenericSetup.registry import _export_step_registry
+
+
+class ImportStepsView(BrowserView):
+    def __init__(self, context, request):
+        BrowserView.__init__(self, context, request)
+        self.global_registry=_import_step_registry
+        self.tool_registry=context.getImportStepRegistry()
+
+    def invalidSteps(self):
+        steps=self.tool_registry.listStepMetadata()
+        steps=[step for step in steps if step['invalid']]
+        return steps
+
+
+    def doubleSteps(self):
+        steps=set(self.tool_registry.listSteps())
+        globals=set(self.global_registry.listSteps())
+        steps=steps.intersection(globals)
+        steps=[self.tool_registry.getStepMetadata(step) for step in steps]
+        steps.sort()
+        return steps
+
+
+
+class ExportStepsView(ImportStepsView):
+    def __init__(self, context, request):
+        BrowserView.__init__(self, context, request)
+        self.global_registry=_export_step_registry
+        self.tool_registry=context.getExportStepRegistry()
+


Property changes on: Products.GenericSetup/trunk/Products/GenericSetup/browser/manage.py
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: Products.GenericSetup/trunk/Products/GenericSetup/tool.py
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/tool.py	2007-12-28 10:34:52 UTC (rev 82475)
+++ Products.GenericSetup/trunk/Products/GenericSetup/tool.py	2007-12-28 11:01:24 UTC (rev 82476)
@@ -538,6 +538,9 @@
                        {'label' : 'Comparison',
                         'action' : 'manage_showDiff'
                        },
+                       {'label' : 'Manage',
+                        'action' : 'manage_stepRegistry'
+                       },
                       )
                     + Folder.manage_options[3:] # skip "View", "Properties"
                      )
@@ -829,6 +832,27 @@
                                           ignore_blanks,
                                          )
 
+    security.declareProtected(ManagePortal, 'manage_stepRegistry')
+    manage_stepRegistry = PageTemplateFile('sutManage', _wwwdir)
+
+    security.declareProtected(ManagePortal, 'manage_deleteImportSteps')
+    def manage_deleteImportSteps(self, ids, request=None):
+        if request is None:
+            request = self.REQUEST
+        for id in ids:
+            self._import_registry.unregisterStep(id)
+        url = self.absolute_url()
+        request.RESPONSE.redirect("%s/manage_stepRegistry" % url)
+
+    security.declareProtected(ManagePortal, 'manage_deleteExportSteps')
+    def manage_deleteExportSteps(self, ids, request=None):
+        if request is None:
+            request = self.REQUEST
+        for id in ids:
+            self._export_registry.unregisterStep(id)
+        url = self.absolute_url()
+        request.RESPONSE.redirect("%s/manage_stepRegistry" % url)
+
     #
     # Upgrades management
     #

Added: Products.GenericSetup/trunk/Products/GenericSetup/www/sutManage.zpt
===================================================================
--- Products.GenericSetup/trunk/Products/GenericSetup/www/sutManage.zpt	                        (rev 0)
+++ Products.GenericSetup/trunk/Products/GenericSetup/www/sutManage.zpt	2007-12-28 11:01:24 UTC (rev 82476)
@@ -0,0 +1,226 @@
+<html xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
+      xmlns:tal="http://xml.zope.org/namespaces/tal"
+      xmlns:metal="http://xml.zope.org/namespaces/metal"
+      xml:lang="en" lang="en">
+
+<h1 tal:replace="structure context/manage_page_header">PAGE HEADER</h1>
+<h2 tal:define="manage_tabs_message options/manage_tabs_message | nothing"
+    tal:replace="structure context/manage_tabs">TABS</h2>
+
+<h2>Manage steps registry</h2>
+
+<p class="form-help">
+This form allows one to manage the persistent import and export step
+registries. Steps registered via ZCML are not shown here.
+</p>
+
+<h2>Import steps</h2>
+
+<tal:block define="view context/@@manage_importsteps;
+                   invalid_steps view/invalidSteps;
+                   double_steps view/doubleSteps;">
+
+  <tal:block condition="not:invalid_steps">
+    <p>
+      There are no import steps with an invalid step handler.
+    </p>
+  </tal:block>
+
+  <tal:block condition="invalid_steps">
+    <h3>Steps with invalid step handlers</h3>
+
+    <form action="." method="POST"
+      tal:attributes="action string:${context/absolute_url}/manage_stepRegistry">
+      <input type="hidden" name="registry" value="import"/>
+      <table cellspacing="0" cellpadding="4">
+        <thead>
+          <tr class="list-header">
+            <th>Sel.</th>
+            <th>Title / Description</th>
+            <th>Handler</th>
+          </tr>
+        </thead>
+        <tbody>
+          <tr tal:repeat="step invalid_steps">
+            <td>
+              <input type="checkbox" name="ids:list" tal:attributes="value step/id"/>
+            </td>
+            <td>
+              <span tal:replace="step/title">Step title</span><br/>
+              <em tal:content="step/description">Step description</em>
+            </td>
+            <td tal:content="step/handler">
+              Products.StepProduct.setuphandlers.handler
+            </td>
+          </tr>
+          <tr>
+            <td/>
+            <td colspan="2">
+              <input type="submit" class="form-element"
+                     name="manage_deleteImportSteps:method"
+                     value=" Delete selected steps "/>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </form>
+  </tal:block>
+
+  <tal:block condition="not:double_steps">
+    <p>
+      There are no import steps that are both registered via ZCML
+      and listed in the persistent step registry.
+    </p>
+  </tal:block>
+
+  <tal:block condition="double_steps">
+    <h3>Doubly registered steps</h3>
+    <p>
+      These import steps are both registered via ZCML and listed in the
+      persistent step registry.
+    </p>
+
+    <form action="." method="POST"
+      tal:attributes="action string:${context/absolute_url}/manage_stepRegistry">
+      <input type="hidden" name="registry" value="import"/>
+      <table cellspacing="0" cellpadding="4">
+        <thead>
+          <tr class="list-header">
+            <th>Sel.</th>
+            <th>Title / Description</th>
+            <th>Handler</th>
+          </tr>
+        </thead>
+        <tbody>
+          <tr tal:repeat="step double_steps">
+            <td>
+              <input type="checkbox" name="ids:list" tal:attributes="value step/id"/>
+            </td>
+            <td>
+              <span tal:replace="step/title">Step title</span><br/>
+              <em tal:content="step/description">Step description</em>
+            </td>
+            <td tal:content="step/handler">
+              Products.StepProduct.setuphandlers.handler
+            </td>
+          </tr>
+          <tr>
+            <td/>
+            <td colspan="2">
+              <input type="submit" class="form-element"
+                     name="manage_deleteImportSteps:method"
+                     value=" Delete selected steps "/>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </form>
+  </tal:block>
+</tal:block>
+
+<h2>Export steps</h2>
+
+<tal:block define="view context/@@manage_exportsteps;
+                   invalid_steps view/invalidSteps;
+                   double_steps view/doubleSteps;">
+
+  <tal:block condition="not:invalid_steps">
+    <p>
+      There are no export steps with an invalid step handler.
+    </p>
+  </tal:block>
+
+  <tal:block condition="invalid_steps">
+    <h3>Steps with invalid step handlers</h3>
+
+    <form action="." method="POST"
+      tal:attributes="action string:${context/absolute_url}/manage_stepRegistry">
+      <input type="hidden" name="registry" value="export"/>
+      <table cellspacing="0" cellpadding="4">
+        <thead>
+          <tr class="list-header">
+            <th>Sel.</th>
+            <th>Title / Description</th>
+            <th>Handler</th>
+          </tr>
+        </thead>
+        <tbody>
+          <tr tal:repeat="step invalid_steps">
+            <td>
+              <input type="checkbox" name="ids:list" tal:attributes="value step/id"/>
+            </td>
+            <td>
+              <span tal:replace="step/title">Step title</span><br/>
+              <em tal:content="step/description">Step description</em>
+            </td>
+            <td tal:content="step/handler">
+              Products.StepProduct.setuphandlers.handler
+            </td>
+          </tr>
+          <tr>
+            <td/>
+            <td colspan="2">
+              <input type="submit" class="form-element"
+                     name="manage_deleteExportSteps:method"
+                     value=" Delete selected steps "/>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </form>
+  </tal:block>
+
+  <tal:block condition="not:double_steps">
+    <p>
+      There are no export steps that are both registered via ZCML
+      and listed in the persistent step registry.
+    </p>
+  </tal:block>
+
+  <tal:block condition="double_steps">
+    <h3>Doubly registered steps</h3>
+    <p>
+      These export steps are both registered via ZCML and listed in the
+      persistent step registry.
+    </p>
+
+    <form action="." method="POST"
+      tal:attributes="action string:${context/absolute_url}/manage_stepRegistry">
+      <input type="hidden" name="registry" value="export"/>
+      <table cellspacing="0" cellpadding="4">
+        <thead>
+          <tr class="list-header">
+            <th>Sel.</th>
+            <th>Title / Description</th>
+            <th>Handler</th>
+          </tr>
+        </thead>
+        <tbody>
+          <tr tal:repeat="step double_steps">
+            <td>
+              <input type="checkbox" name="ids:list" tal:attributes="value step/id"/>
+            </td>
+            <td>
+              <span tal:replace="step/title">Step title</span><br/>
+              <em tal:content="step/description">Step description</em>
+            </td>
+            <td tal:content="step/handler">
+              Products.StepProduct.setuphandlers.handler
+            </td>
+          </tr>
+          <tr>
+            <td/>
+            <td colspan="2">
+              <input type="submit" class="form-element"
+                     name="manage_deleteExportSteps:method"
+                     value=" Delete selected steps "/>
+            </td>
+          </tr>
+        </tbody>
+      </table>
+    </form>
+  </tal:block>
+</tal:block>
+<h1 tal:replace="structure context/manage_page_footer">PAGE FOOTER</h1>
+</html>



More information about the Checkins mailing list