[Checkins] SVN: Products.GenericSetup/branches/1.4/Products/GenericSetup/ Merge r84622 from trunk

Wichert Akkerman wichert at wiggy.net
Wed Mar 12 16:45:08 EDT 2008


Log message for revision 84623:
  Merge r84622 from trunk

Changed:
  U   Products.GenericSetup/branches/1.4/Products/GenericSetup/CHANGES.txt
  U   Products.GenericSetup/branches/1.4/Products/GenericSetup/tests/test_tool.py
  U   Products.GenericSetup/branches/1.4/Products/GenericSetup/tool.py

-=-
Modified: Products.GenericSetup/branches/1.4/Products/GenericSetup/CHANGES.txt
===================================================================
--- Products.GenericSetup/branches/1.4/Products/GenericSetup/CHANGES.txt	2008-03-12 20:43:34 UTC (rev 84622)
+++ Products.GenericSetup/branches/1.4/Products/GenericSetup/CHANGES.txt	2008-03-12 20:45:06 UTC (rev 84623)
@@ -2,7 +2,10 @@
 
   GenericSetup 1.4.0 (unreleased)
 
+    - Make getProfileImportDate handle situations where one object's id
+      is a prefix of another id.
 
+
   GenericSetup 1.4.0-beta (2008/02/07)
 
     - During object manager imports do not throw an error when

Modified: Products.GenericSetup/branches/1.4/Products/GenericSetup/tests/test_tool.py
===================================================================
--- Products.GenericSetup/branches/1.4/Products/GenericSetup/tests/test_tool.py	2008-03-12 20:43:34 UTC (rev 84622)
+++ Products.GenericSetup/branches/1.4/Products/GenericSetup/tests/test_tool.py	2008-03-12 20:45:06 UTC (rev 84623)
@@ -851,6 +851,21 @@
         self.assertEqual(tool.getProfileImportDate('foo:bar'),
                          '2007-03-15T12:34:56Z')
 
+    def test_getProfileImportDate_id_with_prefix(self):
+        # Test if getProfileImportDate does not fail if there is another
+        # item id with id with a longer id which starts with the same
+        # prefix
+        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, '', ''))
+        filename2 = 'import-all-foo_bar-boo-20070315123456.log'
+        tool._setObject(filename2, File(filename2, '', ''))
+        self.assertEqual(tool.getProfileImportDate('foo:bar'),
+                         '2007-03-15T12:34:56Z')
+
     def test_profileVersioning(self):
         site = self._makeSite()
         site.setup_tool = self._makeOne('setup_tool')

Modified: Products.GenericSetup/branches/1.4/Products/GenericSetup/tool.py
===================================================================
--- Products.GenericSetup/branches/1.4/Products/GenericSetup/tool.py	2008-03-12 20:43:34 UTC (rev 84622)
+++ Products.GenericSetup/branches/1.4/Products/GenericSetup/tool.py	2008-03-12 20:45:06 UTC (rev 84623)
@@ -764,13 +764,12 @@
         """
         prefix = ('import-all-%s-' % profile_id).replace(':', '_')
         candidates = [x for x in self.objectIds('File')
-                        if x.startswith(prefix)]
+                        if x[:-18]==prefix and x.endswith('.log')]
         if len(candidates) == 0:
             return None
         candidates.sort()
         last = candidates[-1]
-        stamp = last[len(prefix):-4]
-        assert(len(stamp) == 14)
+        stamp = last[-18:-4]
         return '%s-%s-%sT%s:%s:%sZ' % (stamp[0:4],
                                        stamp[4:6],
                                        stamp[6:8],



More information about the Checkins mailing list