[Checkins] SVN: zope.app.component/trunk/ Deprecate import of ClassDirective.

Dan Korostelev nadako at gmail.com
Thu Feb 5 18:15:15 EST 2009


Log message for revision 96165:
  Deprecate import of ClassDirective.

Changed:
  U   zope.app.component/trunk/CHANGES.txt
  U   zope.app.component/trunk/src/zope/app/component/contentdirective.py
  D   zope.app.component/trunk/src/zope/app/component/tests/test_contentdirective.py

-=-
Modified: zope.app.component/trunk/CHANGES.txt
===================================================================
--- zope.app.component/trunk/CHANGES.txt	2009-02-05 22:46:00 UTC (rev 96164)
+++ zope.app.component/trunk/CHANGES.txt	2009-02-05 23:15:15 UTC (rev 96165)
@@ -9,6 +9,8 @@
   raising a deprecation warning. It was moved in the previous release,
   but some custom directives could possibly use its schemas. 
 
+- Deprecate import of ClassDirective to announce about new location.
+
 3.6.0 (2009-01-31)
 ------------------
 

Modified: zope.app.component/trunk/src/zope/app/component/contentdirective.py
===================================================================
--- zope.app.component/trunk/src/zope/app/component/contentdirective.py	2009-02-05 22:46:00 UTC (rev 96164)
+++ zope.app.component/trunk/src/zope/app/component/contentdirective.py	2009-02-05 23:15:15 UTC (rev 96165)
@@ -18,4 +18,11 @@
 """
 __docformat__ = 'restructuredtext'
 
-from zope.security.metaconfigure import ClassDirective
+import zope.deferredimport
+
+zope.deferredimport.deprecated(
+    "The ``class`` directive implementation was moved to "
+    "zope.security.metaconfigure. This import will stop "
+    "working in Zope 3.6",
+    ClassDirective = 'zope.security.metaconfigure:ClassDirective'
+    )

Deleted: zope.app.component/trunk/src/zope/app/component/tests/test_contentdirective.py
===================================================================
--- zope.app.component/trunk/src/zope/app/component/tests/test_contentdirective.py	2009-02-05 22:46:00 UTC (rev 96164)
+++ zope.app.component/trunk/src/zope/app/component/tests/test_contentdirective.py	2009-02-05 23:15:15 UTC (rev 96165)
@@ -1,206 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001, 2002 Zope Corporation 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.
-#
-##############################################################################
-"""Test 'zope:class' directive.
-
-$Id$
-"""
-import unittest
-from StringIO import StringIO
-
-from zope.component.interfaces import IFactory
-from zope.component.interfaces import ComponentLookupError
-from zope.component.interface import queryInterface
-from zope.configuration.xmlconfig import xmlconfig, XMLConfig
-
-import zope.component
-import zope.security
-import zope.app.component
-from zope.app.testing.placelesssetup import PlacelessSetup
-
-# explicitly import ExampleClass and IExample using full paths
-# so that they are the same objects as resolve will get.
-from zope.app.component.tests.exampleclass import ExampleClass
-from zope.app.component.tests.exampleclass import IExample, IExample2
-
-
-class ParticipationStub(object):
-
-    def __init__(self, principal):
-        self.principal = principal
-        self.interaction = None
-
-
-def configfile(s):
-    return StringIO("""<configure
-      xmlns='http://namespaces.zope.org/zope'
-      i18n_domain='zope'>
-      %s
-      </configure>
-      """ % s)
-
-class TestClassDirective(PlacelessSetup, unittest.TestCase):
-    def setUp(self):
-        super(TestClassDirective, self).setUp()
-        XMLConfig('meta.zcml', zope.app.component)()
-        XMLConfig('meta.zcml', zope.security)()
-
-        try:
-            del ExampleClass.__implements__
-        except AttributeError:
-            pass
-
-    def testEmptyDirective(self):
-        f = configfile("""
-<class class="zope.app.component.tests.exampleclass.ExampleClass">
-</class>
-                       """)
-        xmlconfig(f)
-
-
-    def testImplements(self):
-        self.assertEqual(queryInterface(
-            "zope.app.component.tests.exampleclass.IExample"), None)
-
-        f = configfile("""
-<class class="zope.app.component.tests.exampleclass.ExampleClass">
-  <implements interface="zope.app.component.tests.exampleclass.IExample" />
-</class>
-                       """)
-        xmlconfig(f)
-        self.failUnless(IExample.implementedBy(ExampleClass))
-
-        self.assertEqual(queryInterface(
-            "zope.app.component.tests.exampleclass.IExample"), IExample)
-
-
-    def testMulImplements(self):
-        self.assertEqual(queryInterface(
-            "zope.app.component.tests.exampleclass.IExample"), None)
-        self.assertEqual(queryInterface(
-            "zope.app.component.tests.exampleclass.IExample2"), None)
-
-        f = configfile("""
-<class class="zope.app.component.tests.exampleclass.ExampleClass">
-  <implements interface="
-           zope.app.component.tests.exampleclass.IExample
-           zope.app.component.tests.exampleclass.IExample2
-                       " />
-</class>
-                       """)
-        xmlconfig(f)
-        self.failUnless(IExample.implementedBy(ExampleClass))
-        self.failUnless(IExample2.implementedBy(ExampleClass))
-
-        self.assertEqual(queryInterface(
-            "zope.app.component.tests.exampleclass.IExample"), IExample)
-        self.assertEqual(queryInterface(
-            "zope.app.component.tests.exampleclass.IExample2"),
-                         IExample2)
-
-    def testRequire(self):
-        f = configfile("""
-<permission id="zope.View" title="Zope view permission" />
-<class class="zope.app.component.tests.exampleclass.ExampleClass">
-    <require permission="zope.View"
-                      attributes="anAttribute anotherAttribute" />
-</class>
-                       """)
-        xmlconfig(f)
-
-    def testAllow(self):
-        f = configfile("""
-<class class="zope.app.component.tests.exampleclass.ExampleClass">
-    <allow attributes="anAttribute anotherAttribute" />
-</class>
-                       """)
-        xmlconfig(f)
-
-    def testMimic(self):
-        f = configfile("""
-<class class="zope.app.component.tests.exampleclass.ExampleClass">
-    <require like_class="zope.app.component.tests.exampleclass.ExampleClass" />
-</class>
-                       """)
-        xmlconfig(f)
-
-
-class TestFactorySubdirective(PlacelessSetup, unittest.TestCase):
-    def setUp(self):
-        super(TestFactorySubdirective, self).setUp()
-        XMLConfig('meta.zcml', zope.app.component)()
-        XMLConfig('meta.zcml', zope.security)()
-
-    def testFactory(self):
-        f = configfile("""
-<permission id="zope.Foo" title="Zope Foo Permission" />
-
-<class class="zope.app.component.tests.exampleclass.ExampleClass">
-  <factory
-      id="test.Example"
-      title="Example content"
-      description="Example description"
-      />
-</class>
-                       """)
-        xmlconfig(f)
-        factory = zope.component.getUtility(IFactory, 'test.Example')
-        self.assertEquals(factory.title, "Example content")
-        self.assertEquals(factory.description, "Example description")
-
-    def testFactoryNoId(self):
-        f = configfile("""
-<permission id="zope.Foo" title="Zope Foo Permission" />
-
-<class class="zope.app.component.tests.exampleclass.ExampleClass">
-    <factory
-      title="Example content"
-      description="Example description"
-    />
-</class>
-                       """)
-        xmlconfig(f)
-        self.assertRaises(ComponentLookupError, zope.component.getUtility,
-                          IFactory, 'Example')
-        factory = zope.component.getUtility(
-            IFactory, 'zope.app.component.tests.exampleclass.ExampleClass')
-        self.assertEquals(factory.title, "Example content")
-        self.assertEquals(factory.description, "Example description")
-
-
-    def testFactoryPublicPermission(self):
-
-        f = configfile("""
-<class class="zope.app.component.tests.exampleclass.ExampleClass">
-    <factory
-      id="test.Example"
-      title="Example content"
-      description="Example description"
-    />
-</class>
-            """)
-        xmlconfig(f)
-        factory = zope.component.getUtility(IFactory, 'test.Example')
-        self.assert_(hasattr(factory, '__Security_checker__'))
-
-
-def test_suite():
-    suite = unittest.TestSuite()
-    loader = unittest.TestLoader()
-    suite.addTest(loader.loadTestsFromTestCase(TestClassDirective))
-    suite.addTest(loader.loadTestsFromTestCase(TestFactorySubdirective))
-    return suite
-
-
-if __name__=='__main__':
-    unittest.TextTestRunner().run(test_suite())



More information about the Checkins mailing list