[Zope3-checkins] CVS: Zope3/src/zope/app/component/tests - test_contentdirective.py:1.1.2.1

Steve Alexander steve@cat-box.net
Wed, 14 May 2003 13:44:40 -0400


Update of /cvs-repository/Zope3/src/zope/app/component/tests
In directory cvs.zope.org:/tmp/cvs-serv32636/src/zope/app/component/tests

Modified Files:
      Tag: stevea-decorators-branch
	test_contentdirective.py 
Log Message:
Decorators are now really roughly integrated into zope on this branch.
Still to do:

  * The decorator registry needs an interface and some tests.

  * The decorator registry should be using a type registry rather than
    a simple dict, so that you don't need to keep declaring decorators
    for all the different subtypes of a container that doesn't manage
    its own context.

  * Fix various tests that explicitly use ZopeContainerAdapter.

  * Document use of decorators in Zope 3.

  * Get this work reviewed and discussed.

The first three points should be complete by the end of tomorrow.



=== Zope3/src/zope/app/component/tests/test_contentdirective.py 1.1 => 1.1.2.1 ===
--- Zope3/src/zope/app/component/tests/test_contentdirective.py:1.1	Mon May 12 12:32:40 2003
+++ Zope3/src/zope/app/component/tests/test_contentdirective.py	Wed May 14 13:44:09 2003
@@ -30,6 +30,7 @@
 from zope.component import getService
 from zope.app.services.servicenames import Factories
 from zope.app.component.globalinterfaceservice import queryInterface
+from zope.app.component.decoratorservice import queryDecoratorForClass
 
 # explicitly import ExampleClass and IExample using full paths
 # so that they are the same objects as resolve will get.
@@ -126,11 +127,23 @@
     def testMimic(self):
         f = configfile("""
 <content class="zope.app.component.tests.exampleclass.ExampleClass">
-    <require like_class="zope.app.component.tests.exampleclass.ExampleClass" />
+    <require like_class="zope.app.component.tests.exampleclass.ExampleClass"/>
 </content>
                        """)
         xmlconfig(f)
 
+    def testDecorate(self):
+        from zope.app.component.decoratorservice import registerDecorator
+        # The second arg should be an IDecoratorSpec instance.
+        registerDecorator('zope.app.container.contextdecorator', 1)
+        f = configfile("""
+<content class="zope.app.component.tests.exampleclass.ExampleClass">
+    <decorate decorator="zope.app.container.contextdecorator" type="context"/>
+</content>
+                       """)
+        xmlconfig(f)
+        self.assertEquals(queryDecoratorForClass(ExampleClass, 'context'),
+                          'zope.app.container.contextdecorator')
 
 class TestFactorySubdirective(PlacelessSetup, unittest.TestCase):
     def setUp(self):