[Checkins] SVN: GenericSetup/branches/tseaver-bbq_sprint/ Added a
"last imported" date to the list of extension profiles, and to the
Tres Seaver
tseaver at palladion.com
Fri Mar 16 16:16:29 EDT 2007
Log message for revision 73238:
Added a "last imported" date to the list of extension profiles, and to the
baseline profile.
Renamed the "Properties" tab to "Profiles".
Changed:
U GenericSetup/branches/tseaver-bbq_sprint/CHANGES.txt
U GenericSetup/branches/tseaver-bbq_sprint/interfaces.py
U GenericSetup/branches/tseaver-bbq_sprint/tests/test_tool.py
U GenericSetup/branches/tseaver-bbq_sprint/tool.py
U GenericSetup/branches/tseaver-bbq_sprint/www/sutProperties.zpt
-=-
Modified: GenericSetup/branches/tseaver-bbq_sprint/CHANGES.txt
===================================================================
--- GenericSetup/branches/tseaver-bbq_sprint/CHANGES.txt 2007-03-16 19:57:01 UTC (rev 73237)
+++ GenericSetup/branches/tseaver-bbq_sprint/CHANGES.txt 2007-03-16 20:16:28 UTC (rev 73238)
@@ -2,6 +2,11 @@
GenericSetup 1.3-beta (unreleased)
+ - Added a "last imported" date to the list of extension profiles,
+ and to the baseline profile.
+
+ - Renamed the "Properties" tab to "Profiles".
+
- Removed the 'create_report' decoy in the ZMI view methods: there was
never any UI for passing any value other than the default, anyway, and
the report objects are too useful to omit.
Modified: GenericSetup/branches/tseaver-bbq_sprint/interfaces.py
===================================================================
--- GenericSetup/branches/tseaver-bbq_sprint/interfaces.py 2007-03-16 19:57:01 UTC (rev 73237)
+++ GenericSetup/branches/tseaver-bbq_sprint/interfaces.py 2007-03-16 20:16:28 UTC (rev 73238)
@@ -613,7 +613,13 @@
(c.f: 'diff -wbB')
"""
+ def getProfileImportDate(profile_id):
+ """ Return the last date an extension was imported.
+ o The result will be a string, formated as IS0.
+ """
+
+
class IWriteLogger(Interface):
"""Write methods used by the python logging Logger.
Modified: GenericSetup/branches/tseaver-bbq_sprint/tests/test_tool.py
===================================================================
--- GenericSetup/branches/tseaver-bbq_sprint/tests/test_tool.py 2007-03-16 19:57:01 UTC (rev 73237)
+++ GenericSetup/branches/tseaver-bbq_sprint/tests/test_tool.py 2007-03-16 20:16:28 UTC (rev 73238)
@@ -304,8 +304,10 @@
def test_runAllImportSteps_sorted_default_purge( self ):
TITLE = 'original title'
+ PROFILE_ID = 'testing'
site = self._makeSite( TITLE )
tool = self._makeOne('setup_tool').__of__( site )
+ tool._import_context_id = PROFILE_ID
registry = tool.getImportStepRegistry()
registry.registerStep( 'dependable', '1'
@@ -334,6 +336,10 @@
self.assertEqual( site.title, TITLE.replace( ' ', '_' ).upper() )
self.failUnless( site.purged )
+ prefix = 'import-all-%s' % PROFILE_ID
+ logged = [x for x in tool.objectIds('File') if x.startswith(prefix)]
+ self.assertEqual(len(logged), 1)
+
def test_runAllImportSteps_sorted_explicit_purge( self ):
site = self._makeSite()
@@ -636,6 +642,31 @@
self.assertEqual(info['title'], 'Foo')
self.assertEqual(info['type'], 'extension')
+ def test_getProfileImportDate_nonesuch(self):
+ site = self._makeSite()
+ site.setup_tool = self._makeOne('setup_tool')
+ tool = site.setup_tool
+ self.assertEqual(tool.getProfileImportDate('nonesuch'), None)
+
+ def test_getProfileImportDate_simple_id(self):
+ from OFS.Image import File
+ site = self._makeSite()
+ site.setup_tool = self._makeOne('setup_tool')
+ tool = site.setup_tool
+ filename = 'import-all-foo-20070315123456.log'
+ tool._setObject(filename, File(filename, '', ''))
+ self.assertEqual(tool.getProfileImportDate('foo'),
+ '2007-03-15T12:34:56Z')
+
+ def test_getProfileImportDate_id_with_colon(self):
+ from OFS.Image import File
+ site = self._makeSite()
+ site.setup_tool = self._makeOne('setup_tool')
+ tool = site.setup_tool
+ filename = 'import-all-foo_bar-20070315123456.log'
+ tool._setObject(filename, File(filename, '', ''))
+ self.assertEqual(tool.getProfileImportDate('foo:bar'),
+ '2007-03-15T12:34:56Z')
_DEFAULT_STEP_REGISTRIES_EXPORT_XML = """\
Modified: GenericSetup/branches/tseaver-bbq_sprint/tool.py
===================================================================
--- GenericSetup/branches/tseaver-bbq_sprint/tool.py 2007-03-16 19:57:01 UTC (rev 73237)
+++ GenericSetup/branches/tseaver-bbq_sprint/tool.py 2007-03-16 20:16:28 UTC (rev 73238)
@@ -261,7 +261,11 @@
context = self._getImportContext(profile_id, purge_old)
- return self._runImportStepsFromContext(context, purge_old=purge_old)
+ result = self._runImportStepsFromContext(context, purge_old=purge_old)
+ prefix = 'import-all-%s' % profile_id.replace(':', '_')
+ name = self._mangleTimestampName(prefix, 'log')
+ self._createReport(name, result['steps'], result['messages'])
+ return result
security.declareProtected(ManagePortal, 'runAllImportSteps')
def runAllImportSteps(self, purge_old=None):
@@ -381,7 +385,7 @@
# ZMI
#
manage_options = (Folder.manage_options[:1]
- + ({'label' : 'Properties',
+ + ({'label' : 'Profiles',
'action' : 'manage_tool'
},
{'label' : 'Import',
@@ -602,6 +606,27 @@
return tuple(s_infos + p_infos)
+ security.declareProtected(ManagePortal, 'getProfileImportDate')
+ def getProfileImportDate(self, profile_id):
+ """ See ISetupTool.
+ """
+ prefix = ('import-all-%s-' % profile_id).replace(':', '_')
+ candidates = [x for x in self.objectIds('File')
+ if x.startswith(prefix)]
+ if len(candidates) == 0:
+ return None
+ candidates.sort()
+ last = candidates[-1]
+ stamp = last[len(prefix):-4]
+ assert(len(stamp) == 14)
+ return '%s-%s-%sT%s:%s:%sZ' % (stamp[0:4],
+ stamp[4:6],
+ stamp[6:8],
+ stamp[8:10],
+ stamp[10:12],
+ stamp[12:14],
+ )
+
security.declareProtected(ManagePortal, 'manage_createSnapshot')
def manage_createSnapshot(self, RESPONSE, snapshot_id=None):
Modified: GenericSetup/branches/tseaver-bbq_sprint/www/sutProperties.zpt
===================================================================
--- GenericSetup/branches/tseaver-bbq_sprint/www/sutProperties.zpt 2007-03-16 19:57:01 UTC (rev 73237)
+++ GenericSetup/branches/tseaver-bbq_sprint/www/sutProperties.zpt 2007-03-16 20:16:28 UTC (rev 73238)
@@ -1,5 +1,16 @@
<h1 tal:replace="structure context/manage_page_header">PAGE HEADER</h1>
<h2 tal:replace="structure context/manage_tabs">TABS</h2>
+<style type="text/css">
+.warning {
+ color: red;
+ font-weight: bold;
+}
+.info {
+ color: #446688;
+ font-style: italic;
+ margin-left: 2em;
+}
+</style>
<div tal:define="contexts context/listContextInfos;
snaps python: [x for x in contexts if x['type'] == 'snapshot'];
@@ -10,14 +21,22 @@
and 'display: none' or 'display: block';
exts python: [x for x in contexts if x['type'] == 'extension'];
">
-<h3> Setup Tool Properties </h3>
+<h3> Setup Tool Profiles </h3>
<form method="post" action=".">
<fieldset id="baseline_fs">
<legend>Baseline Profile</legend>
- <p>Active baseline: <span tal:content="context_id_display">(none)</span></p>
+ <p>Active baseline: <span tal:content="context_id_display">(none)</span>
+ <tal:whatever
+ tal:define="last python:context.getProfileImportDate(context_id);
+ ">
+ <span class="info"
+ tal:condition="last">
+ Last imported <tal:x tal:content="last">TIMESTAMP</tal:x></span>
+ </tal:whatever>
+ </p>
<div tal:condition="python: context_id != ''">
<script type="text/javascript" lang="JavaScript">
@@ -52,13 +71,19 @@
<fieldset id="extesions_fs">
<legend>Extension Profiles</legend>
<p tal:repeat="extension exts">
- <tal:x tal:define="fid string:extension_${extension/id}">
+ <tal:whatever
+ tal:define="fid string:extension_${extension/id};
+ last python:context.getProfileImportDate(extension['id']);
+ ">
<input type="checkbox" id="extension_0" name="profile_ids:list" value="waaa"
tal:attributes="id fid;
value extension/id;
"/>
<label tal:content="extension/title">TITLE</label>
- </tal:x>
+ <span class="info"
+ tal:condition="last">
+ Last imported <tal:x tal:content="last">TIMESTAMP</tal:x></span>
+ </tal:whatever>
</p>
<p><input type="submit" name="manage_importExtensions:method"
value="Import Selected Extensions" /></p>
More information about the Checkins
mailing list