[Checkins] SVN: Products.CMFDefault/trunk/Products/CMFDefault/upgrade/t Stub for SyndicationTool upgrade step and tests.

Charlie Clark charlie at begeistert.org
Wed Nov 16 10:33:39 UTC 2011


Log message for revision 123365:
  Stub for SyndicationTool upgrade step and tests.

Changed:
  A   Products.CMFDefault/trunk/Products/CMFDefault/upgrade/tests/test_syndication_upgrade.py
  U   Products.CMFDefault/trunk/Products/CMFDefault/upgrade/to23.py

-=-
Added: Products.CMFDefault/trunk/Products/CMFDefault/upgrade/tests/test_syndication_upgrade.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/upgrade/tests/test_syndication_upgrade.py	                        (rev 0)
+++ Products.CMFDefault/trunk/Products/CMFDefault/upgrade/tests/test_syndication_upgrade.py	2011-11-16 10:33:38 UTC (rev 123365)
@@ -0,0 +1,54 @@
+##############################################################################
+#
+# Copyright (c) 2009 Zope Foundation and Contributors.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Syndication Upgrade tests.
+"""
+
+import datetime
+import unittest
+from Testing import ZopeTestCase
+
+import transaction
+
+from AccessControl.SecurityManagement import newSecurityManager
+from AccessControl.User import UnrestrictedUser
+from Products.CMFDefault.testing import FunctionalLayer
+from zope.site.hooks import setSite
+
+
+class FunctionalUpgradeTestCase(ZopeTestCase.FunctionalTestCase):
+
+    layer = FunctionalLayer
+    _setup_fixture = 0
+
+    def setUp(self):
+        super(FunctionalUpgradeTestCase, self).setUp()
+
+    def makeOne(self):
+        """Create an old style SyndicatonInformation for a folder"""
+        from Products.CMFCore.PortalFolder import PortalFolder
+        from Products.CMFDefault.SyndicationInfo import SyndicationInformation
+        folder = PortalFolder(syndicated_folder)
+        info = SyndicationInformation()
+        info.syndBase = datetime.datetime.now()
+        info.syndPeriod = 1
+        info.syndFrequency = 1
+        info.max_items = 5
+
+    def test_nothing(self):
+        pass
+
+
+def test_suite():
+    return unittest.TestSuite((
+        unittest.makeSuite(FunctionalUpgradeTestCase),
+        ))
\ No newline at end of file


Property changes on: Products.CMFDefault/trunk/Products/CMFDefault/upgrade/tests/test_syndication_upgrade.py
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: Products.CMFDefault/trunk/Products/CMFDefault/upgrade/to23.py
===================================================================
--- Products.CMFDefault/trunk/Products/CMFDefault/upgrade/to23.py	2011-11-16 10:32:16 UTC (rev 123364)
+++ Products.CMFDefault/trunk/Products/CMFDefault/upgrade/to23.py	2011-11-16 10:33:38 UTC (rev 123365)
@@ -321,3 +321,24 @@
             sm.registerUtility(tool_obj, iface)
             logger.info('Registered %s for interface %s' % (tool_id,
                                                             tool_interface))
+
+def upgrade_syndicationtool(tool):
+    """Replace SyndicatonInformation objects with SyndicationInfo adapters"""
+
+    def change_to_adapter(SyndicationInformation):
+        """Read values from the SyndicationInformation object and set them on
+        the adapter"""
+        folder = aq_parent(aq_inner(SyndicationInformation))
+        adapter = getAdapter(folder, ISyndicationInfo)
+        adapter.period = SyndicationInformation.syndPeriod
+        adapter.base = SyndicationInformation.syndBase
+        adapter.frequency = SyndicationInformation.syndFrequency
+        adapter.max_items = SyndicationInformation.max_items
+        folder._delObj(SyndicationInformation.getId())
+
+    # convert Zope.DateTime to python.datetime on the tool
+
+    # migrate existing SyndicationInformation objects to adapter based Infos.
+    portal = aq_parent(aq_inner(tool))
+    portal.ZopeFindAndApply(obj_metatypes=["SyndicationInformation"],
+                        apply_func=change_to_adapter)
\ No newline at end of file



More information about the checkins mailing list