Martin Aspeli, on 2007-05-11:
> Maurits van Rees-3 wrote:
>> In zcml you can register your profile as providing either
>> Products.GenericSetup.interfaces.BASE or
>> Products.GenericSetup.interfaces.EXTENSION
>>
>> It could help to have this as an option:
>> Products.GenericSetup.interfaces.MIGRATION
>>
>> Then portal_setup could list this differently.
>>
>
> Interesting. Are you up for exploring that option? The MIGRATION
> constant/interface could be defined somewhere else than Products.GS of
> course. :p
It could look something like this. This is for GenericSetup 1.2 as
used in the Plone 2.5 svn bundle. Instead of the one drop down with
all GS profiles it gives you a maximum of four drop downs: for
snapshots, base, extension and migration profiles.
$ svn info
Path: .
URL: svn://svn.zope.org/repos/main/GenericSetup/branches/1.2
Repository Root: svn://svn.zope.org/repos/main
Repository UUID: 62d5b8a3-27da-0310-9561-8e5933582275
Revision: 75683
Node Kind: directory
Schedule: normal
Last Changed Author: tseaver
Last Changed Rev: 74724
Last Changed Date: 2007-04-24 23:12:07 +0200 (di, 24 apr 2007)
$ svn diff
Index: www/sutProperties.zpt
===================================================================
--- www/sutProperties.zpt (revision 75683)
+++ www/sutProperties.zpt (working copy)
@@ -3,35 +3,74 @@
<h3> Setup Tool Properties </h3>
+<p>Active site configuration is:
+<strong tal:content="context/getImportContextTitle" />.
+</p>
+
+<h4> Steps to take </h4>
+
+<ol>
+ <li>
+ Choose <strong>one</strong> site configuration by selecting either
+ a snapshot or a base, extension or migration profile. Not all of
+ these options are always available.
+ </li>
+ <li>
+ Go to the 'import' tab to apply one or more steps from your chosen
+ configuration.
+ </li>
+</ol>
+
+<tal:config define="context_id context/getImportContextID">
+<tal:snapshots
+ define="config_label string:Snapshot configurations;
+ infos context/listSnapshotInfos;">
+
+<metal:config define-macro="configuration-block">
<form method="post" action="manage_updateToolProperties">
<table>
-
- <tr valign="top">
+ <tr valign="top"
+ tal:condition="infos">
<td>
- <div class="form-label">Active site configuration:</div>
+ <div class="form-label"
+ tal:content="config_label">Active site configuration:</div>
</td>
<td>
- <select name="context_id"
- tal:define="context_id context/getImportContextID">
+ <select name="context_id">
<option value="context-CONTEXT_ID"
- tal:repeat="context_info context/listContextInfos"
+ tal:repeat="context_info infos"
tal:attributes="selected python:context_id == context_info['id'];
value context_info/id"
tal:content="context_info/title"
>CONTEXT_TITLE</option>
</select>
</td>
- </tr>
-
- <tr valign="top">
- <td />
<td>
<input class="form-element" type="submit" value=" Update " />
</td>
</tr>
-
</table>
</form>
+</metal:config>
+</tal:snapshots>
+
+ <tal:base
+ define="config_label string:Base profiles;
+ infos context/listBaseProfileInfos;">
+ <metal:block use-macro="context/manage_tool/macros/configuration-block" />
+ </tal:base>
+
+ <tal:extension
+ define="config_label string:Extension profiles;
+ infos context/listExtensionProfileInfos;">
+ <metal:block use-macro="context/manage_tool/macros/configuration-block" />
+ </tal:extension>
+
+ <tal:migration
+ define="config_label string:Migration profiles;
+ infos context/listMigrationProfileInfos;">
+ <metal:block use-macro="context/manage_tool/macros/configuration-block" />
+ </tal:migration>
+</tal:config>
<h1 tal:replace="structure context/manage_page_footer">PAGE FOOTER</h1>
Index: interfaces.py
===================================================================
--- interfaces.py (revision 75683)
+++ interfaces.py (working copy)
@@ -21,7 +21,7 @@
# Please note that these values may change. Always import
# the values from here instead of using the values directly.
-BASE, EXTENSION = 1, 2
+BASE, EXTENSION, MIGRATION = 1, 2, 3
SKIPPED_FILES = ('CVS', '.svn', '_svn', '_darcs')
SKIPPED_SUFFIXES = ('~',)
Index: tool.py
===================================================================
--- tool.py (revision 75683)
+++ tool.py (working copy)
@@ -28,7 +28,9 @@
from zope.interface import implements
from zope.interface import implementedBy
+from interfaces import BASE
from interfaces import EXTENSION
+from interfaces import MIGRATION
from interfaces import ISetupTool
from interfaces import SKIPPED_FILES
from permissions import ManagePortal
@@ -172,6 +174,17 @@
"""
return self._import_context_id
+ security.declareProtected(ManagePortal, 'getImportContextTitle')
+ def getImportContextTitle(self):
+
+ """ Get the title of the current import context.
+ """
+ id = self.getImportContextID()
+ for info in self.listContextInfos():
+ if info['id'] == id:
+ return info['title']
+ return ''
+
security.declareProtected(ManagePortal, 'setImportContext')
def setImportContext(self, context_id, encoding=None):
@@ -554,6 +567,48 @@
return tuple(s_infos + p_infos)
+ security.declareProtected(ManagePortal, 'listSnapshotInfos')
+ def listSnapshotInfos(self):
+
+ """ List registered snapshots.
+ """
+ s_infos = [{ 'id': 'snapshot-%s' % info['id'],
+ 'title': info['title'] }
+ for info in self.listSnapshotInfo()]
+ return s_infos
+
+ security.declareProtected(ManagePortal, 'listBaseProfileInfos')
+ def listProfileInfosOfType(self, _type):
+
+ """ List registered profiles of a certain type.
+ """
+ p_infos = [{ 'id': 'profile-%s' % info['id'],
+ 'title': info['title'] }
+ for info in self.listProfileInfo()
+ if info['type'] == _type]
+ return p_infos
+
+ security.declareProtected(ManagePortal, 'listBaseProfileInfos')
+ def listBaseProfileInfos(self):
+
+ """ List registered base profiles.
+ """
+ return self.listProfileInfosOfType(BASE)
+
+ security.declareProtected(ManagePortal, 'listExtensionProfileInfos')
+ def listExtensionProfileInfos(self):
+
+ """ List registered extension profiles.
+ """
+ return self.listProfileInfosOfType(EXTENSION)
+
+ security.declareProtected(ManagePortal, 'listMigrationProfileInfos')
+ def listMigrationProfileInfos(self):
+
+ """ List registered migration profiles.
+ """
+ return self.listProfileInfosOfType(MIGRATION)
+
security.declareProtected(ManagePortal, 'manage_createSnapshot')
def manage_createSnapshot(self, RESPONSE, snapshot_id=None):
--
Maurits van Rees | http://maurits.vanrees.org/ [NL]
Work | http://zestsoftware.nl/
"Do not worry about your difficulties in computers,
I can assure you mine are still greater."
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers