[Checkins] SVN: CompositePage/trunk/ Fix deprecation warnings under Zope 2.12+.

Tres Seaver tseaver at palladion.com
Tue Jun 28 10:13:33 EDT 2011


Log message for revision 122018:
  Fix deprecation warnings under Zope 2.12+.
  
  Import normalization.
  
  Unit test normalization.
  
  Header normalization.
  

Changed:
  U   CompositePage/trunk/Products/CompositePage/__init__.py
  U   CompositePage/trunk/Products/CompositePage/composite.py
  U   CompositePage/trunk/Products/CompositePage/designuis.py
  U   CompositePage/trunk/Products/CompositePage/element.py
  U   CompositePage/trunk/Products/CompositePage/interfaces.py
  U   CompositePage/trunk/Products/CompositePage/perm_names.py
  U   CompositePage/trunk/Products/CompositePage/rawfile.py
  U   CompositePage/trunk/Products/CompositePage/slot.py
  U   CompositePage/trunk/Products/CompositePage/slotclass.py
  U   CompositePage/trunk/Products/CompositePage/slotexpr.py
  U   CompositePage/trunk/Products/CompositePage/tests/__init__.py
  U   CompositePage/trunk/Products/CompositePage/tests/test_composite.py
  U   CompositePage/trunk/Products/CompositePage/tests/test_tool.py
  U   CompositePage/trunk/Products/CompositePage/tool.py
  U   CompositePage/trunk/Products/CompositePage/utils.py
  U   CompositePage/trunk/Products/__init__.py
  U   CompositePage/trunk/setup.py

-=-
Modified: CompositePage/trunk/Products/CompositePage/__init__.py
===================================================================
--- CompositePage/trunk/Products/CompositePage/__init__.py	2011-06-28 13:23:53 UTC (rev 122017)
+++ CompositePage/trunk/Products/CompositePage/__init__.py	2011-06-28 14:13:33 UTC (rev 122018)
@@ -3,7 +3,7 @@
 # Copyright (c) 2003 Zope Foundation and Contributors.
 #
 # This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# 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
@@ -11,12 +11,16 @@
 #
 ##############################################################################
 """CompositePage product initialization.
-
-$Id: __init__.py,v 1.7 2004/03/05 21:41:04 shane Exp $
 """
 
-import tool, element, composite, slot, slotclass, designuis, interfaces
-import slotexpr
+from Products.CompositePage import tool
+from Products.CompositePage import element
+from Products.CompositePage import composite
+from Products.CompositePage import slot
+from Products.CompositePage import slotclass
+from Products.CompositePage import designuis
+from Products.CompositePage import interfaces
+from Products.CompositePage import slotexpr
 
 slotexpr.registerSlotExprType()
 

Modified: CompositePage/trunk/Products/CompositePage/composite.py
===================================================================
--- CompositePage/trunk/Products/CompositePage/composite.py	2011-06-28 13:23:53 UTC (rev 122017)
+++ CompositePage/trunk/Products/CompositePage/composite.py	2011-06-28 14:13:33 UTC (rev 122018)
@@ -3,7 +3,7 @@
 # Copyright (c) 2003 Zope Foundation and Contributors.
 #
 # This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# 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
@@ -11,15 +11,13 @@
 #
 ##############################################################################
 """Composite class and supporting code.
-
-$Id: composite.py,v 1.24 2004/04/15 22:13:44 shane Exp $
 """
-
 import os
-import re
 
-import Globals
-import Acquisition
+from AccessControl import ClassSecurityInfo
+from AccessControl.ZopeGuards import guarded_getattr
+from AccessControl.class_init import InitializeClass
+from Acquisition import Explicit
 from Acquisition import aq_base
 from Acquisition import aq_inner
 from Acquisition import aq_parent
@@ -28,13 +26,10 @@
 from OFS.SimpleItem import SimpleItem
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
-from AccessControl import ClassSecurityInfo
-from AccessControl.ZopeGuards import guarded_getattr
 from zope.interface import implements
 
 from Products.CompositePage.interfaces import IComposite
 from Products.CompositePage.interfaces import ISlot
-from Products.CompositePage.interfaces import ISlotGenerator
 from Products.CompositePage.interfaces import CompositeError
 from Products.CompositePage.slot import Slot
 from Products.CompositePage.slot import getIconURL
@@ -45,7 +40,7 @@
 _www = os.path.join(os.path.dirname(__file__), "www")
 
 
-class SlotGenerator(Acquisition.Explicit):
+class SlotGenerator(Explicit):
     """Automatically makes slots available to the template.
 
     Note: instances of this class are shared across threads.
@@ -302,7 +297,7 @@
         """
         return self._v_editing
 
-Globals.InitializeClass(CompositeMixin)
+InitializeClass(CompositeMixin)
 
 
 class SlotCollection(Folder):
@@ -333,7 +328,7 @@
         f._setId("filled_slots")
         self._setObject(f.getId(), f)
 
-Globals.InitializeClass(Composite)
+InitializeClass(Composite)
 
 
 class FailedElement(SimpleItem):

Modified: CompositePage/trunk/Products/CompositePage/designuis.py
===================================================================
--- CompositePage/trunk/Products/CompositePage/designuis.py	2011-06-28 13:23:53 UTC (rev 122017)
+++ CompositePage/trunk/Products/CompositePage/designuis.py	2011-06-28 14:13:33 UTC (rev 122018)
@@ -4,7 +4,7 @@
 # All Rights Reserved.
 # 
 # This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# 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
@@ -12,19 +12,17 @@
 # 
 ##############################################################################
 """Page design UI classes.
-
-$Id: designuis.py,v 1.10 2004/04/06 16:50:25 shane Exp $
 """
-
 import os
 import re
 
-import Globals
-from Acquisition import aq_base, aq_inner, aq_parent
-from OFS.SimpleItem import SimpleItem
-from Products.PageTemplates.PageTemplateFile import PageTemplateFile
 from AccessControl import ClassSecurityInfo
 from AccessControl.ZopeGuards import guarded_getattr
+from AccessControl.class_init import InitializeClass
+from Acquisition import aq_inner
+from Acquisition import aq_parent
+from OFS.SimpleItem import SimpleItem
+from Products.PageTemplates.PageTemplateFile import PageTemplateFile
 
 from Products.CompositePage.rawfile import RawFile
 from Products.CompositePage.rawfile import InterpolatedFile
@@ -242,7 +240,7 @@
             elif close:
                 return close_dialog_html
 
-Globals.InitializeClass(CommonUI)
+InitializeClass(CommonUI)
 
 
 
@@ -265,7 +263,7 @@
     bottom_templates = (PageTemplateFile("bottom.pt", _zmi),
                         ) + CommonUI.bottom_templates
 
-Globals.InitializeClass(ZMIUI)
+InitializeClass(ZMIUI)
 
 
 
@@ -286,7 +284,7 @@
     bottom_templates = (PageTemplateFile("bottom.pt", _cmf),
                         ) + CommonUI.bottom_templates
 
-Globals.InitializeClass(CMFUI)
+InitializeClass(CMFUI)
 
 
 
@@ -342,4 +340,4 @@
         res.append(composite.manage_page_footer())
         return '\n'.join(res)
 
-Globals.InitializeClass(ManualUI)
+InitializeClass(ManualUI)

Modified: CompositePage/trunk/Products/CompositePage/element.py
===================================================================
--- CompositePage/trunk/Products/CompositePage/element.py	2011-06-28 13:23:53 UTC (rev 122017)
+++ CompositePage/trunk/Products/CompositePage/element.py	2011-06-28 14:13:33 UTC (rev 122018)
@@ -3,7 +3,7 @@
 # Copyright (c) 2003 Zope Foundation and Contributors.
 #
 # This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# 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
@@ -11,20 +11,16 @@
 #
 ##############################################################################
 """Composite element.
-
-$Id: element.py,v 1.5 2004/04/14 16:15:29 sidnei Exp $
 """
-
 import os
 
-import Globals
 from AccessControl.SecurityInfo import ClassSecurityInfo
+from AccessControl.class_init import InitializeClass
 from Acquisition import aq_get
 from OFS.SimpleItem import SimpleItem
 from OFS.PropertyManager import PropertyManager
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
 from DocumentTemplate.DT_Util import safe_callable
-
 from zope.interface import implements
 
 from Products.CompositePage.interfaces import ICompositeElement
@@ -99,7 +95,7 @@
         # No tool found, so no inline templates are known.
         return ()
 
-Globals.InitializeClass(CompositeElement)
+InitializeClass(CompositeElement)
 
 
 addElementForm = PageTemplateFile("addElementForm.zpt", _www)

Modified: CompositePage/trunk/Products/CompositePage/interfaces.py
===================================================================
--- CompositePage/trunk/Products/CompositePage/interfaces.py	2011-06-28 13:23:53 UTC (rev 122017)
+++ CompositePage/trunk/Products/CompositePage/interfaces.py	2011-06-28 14:13:33 UTC (rev 122018)
@@ -3,7 +3,7 @@
 # Copyright (c) 2003 Zope Foundation and Contributors.
 #
 # This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# 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
@@ -11,10 +11,7 @@
 #
 ##############################################################################
 """Interfaces and exceptions in the CompositePage product.
-
-$Id: interfaces.py,v 1.14 2004/04/15 22:13:44 shane Exp $
 """
-
 from zope.interface import Attribute
 from zope.interface import Interface
 

Modified: CompositePage/trunk/Products/CompositePage/perm_names.py
===================================================================
--- CompositePage/trunk/Products/CompositePage/perm_names.py	2011-06-28 13:23:53 UTC (rev 122017)
+++ CompositePage/trunk/Products/CompositePage/perm_names.py	2011-06-28 14:13:33 UTC (rev 122018)
@@ -4,7 +4,7 @@
 # All Rights Reserved.
 # 
 # This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# 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
@@ -12,10 +12,7 @@
 # 
 ##############################################################################
 """Names of permissions used by CompositePage.
-
-$Id: perm_names.py,v 1.1 2003/10/01 18:59:31 shane Exp $
 """
 
 change_composites_perm = "Change Composites"
 view_perm = "View"
-

Modified: CompositePage/trunk/Products/CompositePage/rawfile.py
===================================================================
--- CompositePage/trunk/Products/CompositePage/rawfile.py	2011-06-28 13:23:53 UTC (rev 122017)
+++ CompositePage/trunk/Products/CompositePage/rawfile.py	2011-06-28 14:13:33 UTC (rev 122018)
@@ -4,7 +4,7 @@
 # All Rights Reserved.
 # 
 # This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# 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
@@ -12,28 +12,24 @@
 # 
 ##############################################################################
 """Binary data that is stored in a file.
-
-$Id: rawfile.py,v 1.3 2004/04/03 16:35:32 shane Exp $
 """
-
 import os
-from os import stat
-from time import time
+import time
 
-import Acquisition
-from Acquisition import aq_inner, aq_parent
-import Globals
-from Globals import package_home
+from Acquisition import Explicit
+from Acquisition import aq_inner
+from Acquisition import aq_parent
+from App.Common import package_home
 from App.Common import rfc1123_date
 from DateTime import DateTime
 
 
-class RawFile(Acquisition.Explicit):
+class RawFile(Explicit):
     """Binary data stored in external files."""
 
     def __init__(self, path, content_type, _prefix=None):
         if _prefix is None:
-            _prefix = SOFTWARE_HOME
+            _prefix = SOFTWARE_HOME  # XXX Grrr -- why?
         elif type(_prefix) is not type(''):
             _prefix = package_home(_prefix)
         path = os.path.join(_prefix, path)
@@ -45,7 +41,7 @@
         file.close()
         self.content_type = content_type
         self.__name__ = path.split('/')[-1]
-        self.lmt = float(stat(path)[8]) or time()
+        self.lmt = float(os.stat(path)[8]) or time.time()
         self.lmh = rfc1123_date(self.lmt)
 
 

Modified: CompositePage/trunk/Products/CompositePage/slot.py
===================================================================
--- CompositePage/trunk/Products/CompositePage/slot.py	2011-06-28 13:23:53 UTC (rev 122017)
+++ CompositePage/trunk/Products/CompositePage/slot.py	2011-06-28 14:13:33 UTC (rev 122018)
@@ -4,7 +4,7 @@
 # All Rights Reserved.
 # 
 # This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# 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
@@ -12,24 +12,27 @@
 # 
 ##############################################################################
 """Slot class and supporting code.
-
-$Id: slot.py,v 1.21 2004/04/26 09:30:25 gotcha Exp $
 """
-
 import os
 import sys
 from cgi import escape
 
-import Globals
+from AccessControl import ClassSecurityInfo
+from AccessControl.class_init import InitializeClass
 from Acquisition import aq_base
 from Acquisition import aq_inner
 from Acquisition import aq_parent
 from Acquisition import aq_get
-from ZODB.POSException import ConflictError
+try:
+    # Use OrderedFolder if it's available.
+    from OFS.OrderedFolder import OrderedFolder
+except ImportError:
+    # Fall back to normal folders, which happen to retain order anyway.
+    from OFS.Folder import Folder as OrderedFolder
 from OFS.SimpleItem import SimpleItem
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
-from AccessControl import ClassSecurityInfo
 from zLOG import LOG, ERROR
+from ZODB.POSException import ConflictError
 from zope.interface import implements
 
 from Products.CompositePage.interfaces import ICompositeElement
@@ -38,13 +41,6 @@
 from Products.CompositePage.perm_names import change_composites_perm
 
 
-try:
-    # Use OrderedFolder if it's available.
-    from OFS.OrderedFolder import OrderedFolder
-except ImportError:
-    # Fall back to normal folders, which happen to retain order anyway.
-    from OFS.Folder import Folder as OrderedFolder
-
 _www = os.path.join(os.path.dirname(__file__), "www")
 
 target_tag = '''<div class="slot_target" title="Slot: %s [%d]"
@@ -200,7 +196,7 @@
     def _render_add_target(self, slot_id, index, path, obj_id=''):
          return target_tag % (slot_id, index, path, index)
          
-Globals.InitializeClass(Slot)
+InitializeClass(Slot)
 
 
 def getIconURL(obj, icon_base_url):

Modified: CompositePage/trunk/Products/CompositePage/slotclass.py
===================================================================
--- CompositePage/trunk/Products/CompositePage/slotclass.py	2011-06-28 13:23:53 UTC (rev 122017)
+++ CompositePage/trunk/Products/CompositePage/slotclass.py	2011-06-28 14:13:33 UTC (rev 122018)
@@ -4,7 +4,7 @@
 # All Rights Reserved.
 # 
 # This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# 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
@@ -12,13 +12,11 @@
 # 
 ##############################################################################
 """Slot classes.
-
-$Id: slotclass.py,v 1.1 2004/03/02 20:41:44 shane Exp $
 """
-
 import os
 
-from Acquisition import aq_inner, aq_parent
+from Acquisition import aq_inner
+from Acquisition import aq_parent
 from OFS.SimpleItem import SimpleItem
 from OFS.PropertyManager import PropertyManager
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile

Modified: CompositePage/trunk/Products/CompositePage/slotexpr.py
===================================================================
--- CompositePage/trunk/Products/CompositePage/slotexpr.py	2011-06-28 13:23:53 UTC (rev 122017)
+++ CompositePage/trunk/Products/CompositePage/slotexpr.py	2011-06-28 14:13:33 UTC (rev 122018)
@@ -1,22 +1,18 @@
 ##############################################################################
 #
 # Copyright (c) 2003 Zope Foundation and Contributors.
-#
-# This software is subject to the provisions of the Zope Visible Source 
-# License, Version 1.0 (ZVSL).  A copy of the ZVSL should accompany this 
-# distribution.
-#
+# All Rights Reserved.
+# 
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (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
-#
+# FOR A PARTICULAR PURPOSE.
+# 
 ##############################################################################
 """Support for 'slot:' expression type in ZPT.
-
-$Id: slotexpr.py,v 1.5 2004/05/03 16:02:40 sidnei Exp $
 """
-
 import logging
 import re
 

Modified: CompositePage/trunk/Products/CompositePage/tests/__init__.py
===================================================================
--- CompositePage/trunk/Products/CompositePage/tests/__init__.py	2011-06-28 13:23:53 UTC (rev 122017)
+++ CompositePage/trunk/Products/CompositePage/tests/__init__.py	2011-06-28 14:13:33 UTC (rev 122018)
@@ -1,2 +1,14 @@
+##############################################################################
+#
+# Copyright (c) 2003 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.
+#
+##############################################################################
 """CompositePage tests.
 """

Modified: CompositePage/trunk/Products/CompositePage/tests/test_composite.py
===================================================================
--- CompositePage/trunk/Products/CompositePage/tests/test_composite.py	2011-06-28 13:23:53 UTC (rev 122017)
+++ CompositePage/trunk/Products/CompositePage/tests/test_composite.py	2011-06-28 14:13:33 UTC (rev 122018)
@@ -4,44 +4,30 @@
 # All Rights Reserved.
 # 
 # This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# 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.
 # 
 ##############################################################################
-"""Composite tests.
-
-$Id: test_composite.py,v 1.6 2004/05/03 16:02:40 sidnei Exp $
-"""
-
 import unittest
-from zope.testing.cleanup import cleanUp
 
 
-template_text = '''\
-<html>
-<body>
-<div tal:replace="structure slot: slot_a (top) 'Top News Stories'">slot_a</div>
-<span tal:replace="structure slot: slot_b 'Other News'">slot_b</span>
-<div tal:replace="structure context/slots/slot_c">slot_c</div>
-</body>
-</html>
-'''
-
-
 class CompositeTests(unittest.TestCase):
 
     def setUp(self):
-        cleanUp()
+        from zope.testing.cleanup import cleanUp
         from AccessControl.SecurityManagement import noSecurityManager
         from AccessControl.SecurityManager import setSecurityPolicy
-        from Products.CompositePage.tests.test_tool import PermissiveSecurityPolicy
+        from Products.CompositePage.tests.test_tool \
+            import PermissiveSecurityPolicy
+        cleanUp()
         self.old_policy = setSecurityPolicy(PermissiveSecurityPolicy())
         noSecurityManager()
 
     def tearDown(self):
+        from zope.testing.cleanup import cleanUp
         from AccessControl.SecurityManagement import noSecurityManager
         from AccessControl.SecurityManager import setSecurityPolicy
         setSecurityPolicy(self.old_policy)
@@ -50,26 +36,40 @@
 
     def _make_composite(self):
         from OFS.Folder import Folder
+        from ZPublisher.HTTPRequest import HTTPRequest
+        from ZPublisher.HTTPRequest import HTTPResponse
+        from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
+        from Products.CompositePage.composite import Composite
+        from Products.CompositePage.element import CompositeElement
+        from Products.CompositePage.slot import Slot
+
+        TEMPLATE_TEXT = '\n'.join((
+            '<html>',
+            '<body>',
+            """<div tal:replace="structure slot: slot_a (top) """
+                """'Top News Stories'">slot_a</div>""",
+            """<span tal:replace="structure slot: slot_b """
+                """'Other News'">slot_b</span>""",
+            '<div tal:replace="structure context/slots/slot_c">slot_c</div>',
+            '</body>',
+            '</html>',
+        ))
         f = Folder()
         f.getPhysicalPath = lambda: ()
         f.getPhysicalRoot = lambda f=f: f
-        from ZPublisher.HTTPRequest import HTTPRequest
-        f.REQUEST = HTTPRequest('', dict(HTTP_HOST='localhost:8080'), {})
-        from Products.CompositePage.composite import Composite
+        req = f.REQUEST = HTTPRequest('', dict(HTTP_HOST='localhost:8080'), {})
+        req.response = HTTPResponse()
         f.composite = Composite()
         f.composite._setId("composite")
-        from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
         t = ZopePageTemplate(
-            id="template", text=template_text, content_type="text/html")
+            id="template", text=TEMPLATE_TEXT, content_type="text/html")
         f.composite.template = t
-        from Products.CompositePage.slot import Slot
         f.composite.filled_slots.slot_a = slot_a = Slot("slot_a")
         t = f.composite.template
         if t.pt_errors():
             raise SyntaxError(t.pt_errors())
         a1 = ZopePageTemplate(id="a1", text="<b>Slot A</b>")
         f._setObject(a1.id, a1)
-        from Products.CompositePage.element import CompositeElement
         e1 = CompositeElement('e1', f.a1)
         slot_a._setObject(e1.id, e1)
         return f.composite
@@ -87,7 +87,7 @@
         b = b.strip().replace("\n", "")
         self.assertEqual(a, b)
 
-    def testRender(self):
+    def test_render(self):
         self._registerTraversable()
         rendered = self._make_composite()()
         expected = ('<html><body>'
@@ -97,7 +97,7 @@
                     '</body></html>')
         self.assertTextEqual(rendered, expected)
 
-    def testGetManifest(self):
+    def test_getManifest(self):
         self._registerTraversable()
         manifest = self._make_composite().getManifest()
         self.assertEqual(len(manifest), 3)
@@ -122,7 +122,7 @@
             manifest[2]['target_path'], 'composite/filled_slots/slot_c')
         self.assertEqual(len(manifest[2]['elements']), 0)
 
-    def testSlotExprCompilerError(self):
+    def test_slot_expr_compiler_error(self):
         # Bad slot expressions should produce a reasonable error.
         from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
         from zope.tal.taldefs import TALError
@@ -138,19 +138,17 @@
                 raise AssertionError("Expected a syntax error")
         self.assertTrue("syntax error" in msg)
 
-    def testGetSlotClassName(self):
+    def test_getSlotClassName(self):
         self._registerTraversable()
         composite = self._make_composite()
         self.assertEqual(composite.getSlotClassName('slot_a'), 'top')
         self.assertEqual(composite.getSlotClassName('slot_b'), None)
         self.assertEqual(composite.getSlotClassName('slot_c'), None)
-        self.assertRaises(
-            KeyError, composite.getSlotClassName, 'nonexistent_slot')
+        self.assertRaises(KeyError,
+                          composite.getSlotClassName, 'nonexistent_slot')
 
-def test_suite():
-    suite = unittest.TestSuite()
-    suite.addTest(unittest.makeSuite(CompositeTests))
-    return suite
 
-if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')
+def test_suite():
+    return unittest.TestSuite((
+        unittest.makeSuite(CompositeTests),
+    ))

Modified: CompositePage/trunk/Products/CompositePage/tests/test_tool.py
===================================================================
--- CompositePage/trunk/Products/CompositePage/tests/test_tool.py	2011-06-28 13:23:53 UTC (rev 122017)
+++ CompositePage/trunk/Products/CompositePage/tests/test_tool.py	2011-06-28 14:13:33 UTC (rev 122018)
@@ -4,7 +4,7 @@
 # All Rights Reserved.
 # 
 # This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# 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
@@ -12,33 +12,18 @@
 # 
 ##############################################################################
 """Composite tool tests.
-
-$Id: test_tool.py,v 1.4 2004/05/03 16:02:40 sidnei Exp $
 """
-
 import unittest
 
-from OFS.Folder import Folder
-from AccessControl.SecurityManagement import noSecurityManager
-from AccessControl.SecurityManager import setSecurityPolicy
-import AccessControl.User  # Get the "nobody" user defined
 
-from Products.CompositePage.tool import CompositeTool
-from Products.CompositePage.slot import Slot
-from Products.CompositePage.interfaces import CompositeError
-
-
-class PermissiveSecurityPolicy:
-    def validate(*args, **kw):
-        return 1
-
-    def checkPermission(*args, **kw):
-        return 1
-
-
 class ToolTests(unittest.TestCase):
 
     def setUp(self):
+        from AccessControl.SecurityManagement import noSecurityManager
+        from AccessControl.SecurityManager import setSecurityPolicy
+        from OFS.Folder import Folder
+        from Products.CompositePage.slot import Slot
+        from Products.CompositePage.tool import CompositeTool
         self.root = Folder()
         self.root.getPhysicalPath = lambda: ()
         self.root.getPhysicalRoot = lambda r=self.root: r
@@ -58,10 +43,13 @@
         noSecurityManager()
 
     def tearDown(self):
+        from AccessControl.SecurityManagement import noSecurityManager
+        from AccessControl.SecurityManager import setSecurityPolicy
         setSecurityPolicy(self.old_policy)
         noSecurityManager()
 
     def testPreventParentageLoop(self):
+        from Products.CompositePage.interfaces import CompositeError
         self.assertRaises(CompositeError, self.tool.moveElements,
                           ["/slot/foo"], "/slot/foo/zzz", 0)
         self.assertRaises(CompositeError, self.tool.moveElements,
@@ -108,11 +96,15 @@
         self.assertEqual(list(self.root.otherslot.objectIds()), [])
 
 
-def test_suite():
-    suite = unittest.TestSuite()
-    suite.addTest(unittest.makeSuite(ToolTests))
-    return suite
+class PermissiveSecurityPolicy:
+    def validate(*args, **kw):
+        return 1
 
-if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')
+    def checkPermission(*args, **kw):
+        return 1
 
+
+def test_suite():
+    return unittest.TestSuite((
+        unittest.makeSuite(ToolTests),
+    ))

Modified: CompositePage/trunk/Products/CompositePage/tool.py
===================================================================
--- CompositePage/trunk/Products/CompositePage/tool.py	2011-06-28 13:23:53 UTC (rev 122017)
+++ CompositePage/trunk/Products/CompositePage/tool.py	2011-06-28 14:13:33 UTC (rev 122018)
@@ -4,7 +4,7 @@
 # All Rights Reserved.
 # 
 # This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# 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
@@ -12,17 +12,17 @@
 # 
 ##############################################################################
 """Composite tool.
-
-$Id: tool.py,v 1.11 2004/03/02 20:41:44 shane Exp $
 """
 
-import Globals
-from Acquisition import aq_base, aq_parent, aq_inner
+from AccessControl import ClassSecurityInfo
+from AccessControl.ZopeGuards import guarded_getattr
+from AccessControl.class_init import InitializeClass
+from Acquisition import aq_base
 from OFS.SimpleItem import SimpleItem
 from OFS.Folder import Folder
-from OFS.CopySupport import _cb_encode, _cb_decode, cookie_path
-from AccessControl import ClassSecurityInfo
-from AccessControl.ZopeGuards import guarded_getattr
+from OFS.CopySupport import _cb_encode
+from OFS.CopySupport import _cb_decode
+from OFS.CopySupport import cookie_path
 
 from Products.CompositePage.interfaces import ICompositeElement
 from Products.CompositePage.interfaces import ISlot
@@ -247,7 +247,7 @@
             raise ValueError("Clipboard function %s unknown" % func)
         resp.redirect(REQUEST["HTTP_REFERER"])
 
-Globals.InitializeClass(CompositeTool)
+InitializeClass(CompositeTool)
 
 
 def manage_addCompositeTool(dispatcher, REQUEST=None):

Modified: CompositePage/trunk/Products/CompositePage/utils.py
===================================================================
--- CompositePage/trunk/Products/CompositePage/utils.py	2011-06-28 13:23:53 UTC (rev 122017)
+++ CompositePage/trunk/Products/CompositePage/utils.py	2011-06-28 14:13:33 UTC (rev 122018)
@@ -4,7 +4,7 @@
 # All Rights Reserved.
 #
 # This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# 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
@@ -14,12 +14,10 @@
 """Utilities for handling ZODB objects.
 
 (Copied from the Ape product.)
-
-$Id: utils.py,v 1.1 2003/12/28 04:32:47 shane Exp $
 """
-
+from cPickle import Pickler
+from cPickle import Unpickler
 from cStringIO import StringIO
-from cPickle import Pickler, Unpickler
 
 
 def copyOf(source):

Modified: CompositePage/trunk/Products/__init__.py
===================================================================
--- CompositePage/trunk/Products/__init__.py	2011-06-28 13:23:53 UTC (rev 122017)
+++ CompositePage/trunk/Products/__init__.py	2011-06-28 14:13:33 UTC (rev 122018)
@@ -1,3 +1,15 @@
+##############################################################################
+#
+# Copyright (c) 2003 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.
+#
+##############################################################################
 # See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
 try:
     __import__('pkg_resources').declare_namespace(__name__)

Modified: CompositePage/trunk/setup.py
===================================================================
--- CompositePage/trunk/setup.py	2011-06-28 13:23:53 UTC (rev 122017)
+++ CompositePage/trunk/setup.py	2011-06-28 14:13:33 UTC (rev 122018)
@@ -1,3 +1,16 @@
+##############################################################################
+#
+# Copyright (c) 2002 Zope Foundation and Contributors.
+# All Rights Reserved.
+# 
+# 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.
+# 
+##############################################################################
 import os
 from setuptools import setup
 from setuptools import find_packages



More information about the checkins mailing list