[Zope3-checkins] SVN: Zope3/branches/srichter-blow-services/src/zope/app/component/ All tests pass now.

Stephan Richter srichter at cosmos.phy.tufts.edu
Fri Jan 7 10:36:39 EST 2005


Log message for revision 28764:
  All tests pass now.
  

Changed:
  U   Zope3/branches/srichter-blow-services/src/zope/app/component/contentdirective.py
  U   Zope3/branches/srichter-blow-services/src/zope/app/component/meta.zcml
  U   Zope3/branches/srichter-blow-services/src/zope/app/component/metaconfigure.py
  U   Zope3/branches/srichter-blow-services/src/zope/app/component/metadirectives.py
  A   Zope3/branches/srichter-blow-services/src/zope/app/component/tests/adapter.py
  A   Zope3/branches/srichter-blow-services/src/zope/app/component/tests/exampleclass.py
  A   Zope3/branches/srichter-blow-services/src/zope/app/component/tests/factory.py
  A   Zope3/branches/srichter-blow-services/src/zope/app/component/tests/module.py
  U   Zope3/branches/srichter-blow-services/src/zope/app/component/tests/test_directives.py
  A   Zope3/branches/srichter-blow-services/src/zope/app/component/tests/views.py

-=-
Modified: Zope3/branches/srichter-blow-services/src/zope/app/component/contentdirective.py
===================================================================
--- Zope3/branches/srichter-blow-services/src/zope/app/component/contentdirective.py	2005-01-07 15:06:47 UTC (rev 28763)
+++ Zope3/branches/srichter-blow-services/src/zope/app/component/contentdirective.py	2005-01-07 15:36:37 UTC (rev 28764)
@@ -32,7 +32,7 @@
 from zope.app.security.protectclass import protectLikeUnto, protectName
 from zope.app.security.protectclass import protectSetAttribute
 
-from metaconfigure import factory
+from metaconfigure import factory, handler
 
 PublicPermission = 'zope.Public'
 
@@ -45,10 +45,6 @@
     """Security-protection-specific exceptions."""
     pass
 
-def handler(serviceName, methodName, *args, **kwargs):
-    method=getattr(zapi.getGlobalService(serviceName), methodName)
-    method(*args, **kwargs)
-
 class ContentDirective(object):
 
     def __init__(self, _context, class_):
@@ -56,9 +52,6 @@
         self.__class = class_
         if isinstance(self.__class, ModuleType):
             raise ConfigurationError('Content class attribute must be a class')
-        # not used yet
-        #self.__name = class_
-        #self.__normalized_name = _context.getNormalizedName(class_)
         self.__context = _context
 
     def implements(self, _context, interface):
@@ -176,9 +169,9 @@
         id = id or self.__id
         factoryObj = Factory(self.__class, title, description)
 
-        # note factories are all in one pile, services and content,
+        # note factories are all in one pile, utilities and content,
         # so addable names must also act as if they were all in the
-        # same namespace, despite the service/content division
+        # same namespace, despite the utilities/content division
         factory(_context, factoryObj, id, title, description)
 
 

Modified: Zope3/branches/srichter-blow-services/src/zope/app/component/meta.zcml
===================================================================
--- Zope3/branches/srichter-blow-services/src/zope/app/component/meta.zcml	2005-01-07 15:06:47 UTC (rev 28763)
+++ Zope3/branches/srichter-blow-services/src/zope/app/component/meta.zcml	2005-01-07 15:36:37 UTC (rev 28764)
@@ -118,7 +118,7 @@
     <meta:complexDirective
         name="localUtility"
         schema=".metadirectives.IClassDirective"
-        handler=".metaconfigure.LocalUtilityDirective"
+        handler=".contentdirective.LocalUtilityDirective"
         >
 
       <meta:subdirective

Modified: Zope3/branches/srichter-blow-services/src/zope/app/component/metaconfigure.py
===================================================================
--- Zope3/branches/srichter-blow-services/src/zope/app/component/metaconfigure.py	2005-01-07 15:06:47 UTC (rev 28763)
+++ Zope3/branches/srichter-blow-services/src/zope/app/component/metaconfigure.py	2005-01-07 15:36:37 UTC (rev 28764)
@@ -30,7 +30,6 @@
 from zope.app.component.interface import queryInterface
 from zope.app.security.adapter import TrustedAdapterFactory
 
-
 PublicPermission = 'zope.Public'
 
 def handler(methodName, *args, **kwargs):
@@ -44,8 +43,8 @@
         callable = provideInterface,
         args = ('', interface, type)
         )
+    
 
-
 def proxify(ob, checker):
     """Try to get the object proxied with the `checker`, but not too soon
 

Modified: Zope3/branches/srichter-blow-services/src/zope/app/component/metadirectives.py
===================================================================
--- Zope3/branches/srichter-blow-services/src/zope/app/component/metadirectives.py	2005-01-07 15:06:47 UTC (rev 28763)
+++ Zope3/branches/srichter-blow-services/src/zope/app/component/metadirectives.py	2005-01-07 15:36:37 UTC (rev 28764)
@@ -26,7 +26,13 @@
 
 from zope.app.i18n import ZopeMessageIDFactory as _
 
+class IDefaultViewName(zope.interface.Interface):
+    """A string that contains the default view name
 
+    A default view name is used to select a view when a user hasn't
+    specified one.
+    """
+
 class IBasicComponentInformation(zope.interface.Interface):
 
     component = zope.configuration.fields.GlobalObject(

Added: Zope3/branches/srichter-blow-services/src/zope/app/component/tests/adapter.py
===================================================================
--- Zope3/branches/srichter-blow-services/src/zope/app/component/tests/adapter.py	2005-01-07 15:06:47 UTC (rev 28763)
+++ Zope3/branches/srichter-blow-services/src/zope/app/component/tests/adapter.py	2005-01-07 15:36:37 UTC (rev 28764)
@@ -0,0 +1,50 @@
+##############################################################################
+#
+# Copyright (c) 2004 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.
+#
+##############################################################################
+"""Sample adapter class for testing
+
+$Id: adapter.py 26551 2004-07-15 07:06:37Z srichter $
+"""
+
+import zope.interface
+
+class I1(zope.interface.Interface):
+    pass
+
+class I2(zope.interface.Interface):
+    pass
+
+class I3(zope.interface.Interface):
+    pass
+
+class IS(zope.interface.Interface):
+    pass
+
+
+class Adapter(object):
+    def __init__(self, *args):
+        self.context = args
+
+class A1(Adapter):
+    zope.interface.implements(I1)
+
+class A2(Adapter):
+    zope.interface.implements(I2)
+
+class A3(Adapter):
+    zope.interface.implements(I3)
+
+
+def Handler(content, *args):
+    # uninteresting handler
+    content.args = getattr(content, 'args', ()) + (args, )

Added: Zope3/branches/srichter-blow-services/src/zope/app/component/tests/exampleclass.py
===================================================================
--- Zope3/branches/srichter-blow-services/src/zope/app/component/tests/exampleclass.py	2005-01-07 15:06:47 UTC (rev 28763)
+++ Zope3/branches/srichter-blow-services/src/zope/app/component/tests/exampleclass.py	2005-01-07 15:36:37 UTC (rev 28764)
@@ -0,0 +1,30 @@
+##############################################################################
+#
+# Copyright (c) 2003 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.
+#
+##############################################################################
+"""Example test classes
+
+$Id$
+"""
+from zope.interface import Interface
+
+class ExampleClass(object):
+    pass
+
+class IExample(Interface):
+    pass
+
+class IExample2(Interface):
+    pass
+
+class IExampleContainer(Interface):
+    pass

Added: Zope3/branches/srichter-blow-services/src/zope/app/component/tests/factory.py
===================================================================
--- Zope3/branches/srichter-blow-services/src/zope/app/component/tests/factory.py	2005-01-07 15:06:47 UTC (rev 28763)
+++ Zope3/branches/srichter-blow-services/src/zope/app/component/tests/factory.py	2005-01-07 15:36:37 UTC (rev 28764)
@@ -0,0 +1,44 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Factory tests.
+
+$Id: factory.py 26551 2004-07-15 07:06:37Z srichter $
+"""
+from zope.component.interfaces import IFactory
+from zope.interface import Interface, implements, implementedBy
+
+class IX(Interface):
+    """the dummy interface which class X supposedly implements,
+    according to the factory"""
+
+class IFoo(Interface):
+    """an even more dummy interface just for testing """
+
+class X(object):
+    implements(IX)
+    def __init__(self, *args, **kwargs):
+        self.args=args
+        self.kwargs=kwargs
+
+
+class ClassFactoryWrapper(object):
+    implements(IFactory)
+    def __init__(self, klass):
+        self.__klass=klass
+    def __call__(self, *args, **kwargs):
+        return self.__klass(*args, **kwargs)
+    def getInterfaces(self):
+        return implementedBy(self.__klass)
+
+f=ClassFactoryWrapper(X)

Added: Zope3/branches/srichter-blow-services/src/zope/app/component/tests/module.py
===================================================================
--- Zope3/branches/srichter-blow-services/src/zope/app/component/tests/module.py	2005-01-07 15:06:47 UTC (rev 28763)
+++ Zope3/branches/srichter-blow-services/src/zope/app/component/tests/module.py	2005-01-07 15:36:37 UTC (rev 28764)
@@ -0,0 +1,58 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Preliminaries to hookup a test suite with the external TestModule.
+
+This is necessary because the test framework interferes with seeing changes in
+the running modules via the module namespace.  This enables having some
+subject classes, instances, permissions, etc, that don't live in the test
+modules, themselves.
+
+$Id$
+"""
+from zope.interface import Interface
+from zope.schema import Text
+
+class I(Interface):
+    def m1():
+        pass
+    def m2():
+        pass
+
+class I2(I):
+    def m4():
+        pass
+
+class I3(Interface):
+    def m3():
+        pass
+
+class I4(Interface):
+    def m2():
+        pass
+
+
+class S(Interface):
+    foo = Text()
+    bar = Text()
+    baro = Text(readonly=True)
+
+class S2(Interface):
+    foo2 = Text()
+    bar2 = Text()
+
+
+template_bracket = """<configure
+   xmlns="http://namespaces.zope.org/zope">
+   %s
+</configure>"""

Modified: Zope3/branches/srichter-blow-services/src/zope/app/component/tests/test_directives.py
===================================================================
--- Zope3/branches/srichter-blow-services/src/zope/app/component/tests/test_directives.py	2005-01-07 15:06:47 UTC (rev 28763)
+++ Zope3/branches/srichter-blow-services/src/zope/app/component/tests/test_directives.py	2005-01-07 15:36:37 UTC (rev 28764)
@@ -22,24 +22,31 @@
 
 from zope.interface import Interface, implements
 from zope.testing.doctestunit import DocTestSuite
-from zope.app.component.metaconfigure import interface
-from zope.app.content.interfaces import IContentType
+from zope.component.tests.request import Request
+from zope.component import createObject
 
 from zope.configuration.xmlconfig import xmlconfig, XMLConfig
 from zope.configuration.exceptions import ConfigurationError
+from zope.configuration.xmlconfig import ZopeXMLConfigurationError
 
 from zope.security.proxy import removeSecurityProxy
 from zope.security.proxy import getTestProxyItems
+from zope.security.checker import ProxyFactory
+from zope.security.checker import selectChecker
 
 import zope.app.component
 from zope.component.exceptions import ComponentLookupError
 
 from zope.app import zapi
 from zope.app.tests.placelesssetup import PlacelessSetup
+from zope.app.component.metaconfigure import interface
 from zope.app.component.tests.views import IV, IC, V1, VZMI, R1, RZMI, IR
-from zope.component.tests.request import Request
-from zope.security.checker import ProxyFactory
+from zope.app.content.interfaces import IContentType
+from zope.app.component.interface import queryInterface
 
+from zope.app.component.tests import module, exampleclass
+from zope.app.component.interface import queryInterface
+
 # TODO: tests for other directives needed
 
 atre = re.compile(' at [0-9a-fA-Fx]+')
@@ -961,7 +968,7 @@
 
 class TestFactoryDirective(PlacelessSetup, unittest.TestCase):
     def setUp(self):
-        super(Test, self).setUp()
+        super(TestFactoryDirective, self).setUp()
         XMLConfig('meta.zcml', zope.app.component)()
         XMLConfig('meta.zcml', zope.app.security)()
 
@@ -977,7 +984,7 @@
 </content>''')
         xmlconfig(f)
         obj = createObject(None, 'test.Example')
-        self.failUnless(zapi.isinstance(obj, ExampleClass))
+        self.failUnless(zapi.isinstance(obj, exampleclass.ExampleClass))
 
 
 
@@ -1001,7 +1008,7 @@
 class TestRequireDirective(PlacelessSetup, unittest.TestCase):
 
     def setUp(self):
-        super(Test, self).setUp()
+        super(TestRequireDirective, self).setUp()
         defineDirectives()
 
         class B(object):

Added: Zope3/branches/srichter-blow-services/src/zope/app/component/tests/views.py
===================================================================
--- Zope3/branches/srichter-blow-services/src/zope/app/component/tests/views.py	2005-01-07 15:06:47 UTC (rev 28763)
+++ Zope3/branches/srichter-blow-services/src/zope/app/component/tests/views.py	2005-01-07 15:36:37 UTC (rev 28764)
@@ -0,0 +1,60 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Views test.
+
+$Id: views.py 26551 2004-07-15 07:06:37Z srichter $
+"""
+from zope.interface import Interface, implements
+
+class IR(Interface):
+    pass
+
+class IV(Interface):
+    def index():
+        pass
+
+class IC(Interface): pass
+
+class V1(object):
+    implements(IV)
+
+    def __init__(self, context, request):
+        self.context = context
+        self.request = request
+
+    def index(self):
+        return 'V1 here'
+
+    def action(self):
+        return 'done'
+
+class VZMI(V1):
+    def index(self):
+        return 'ZMI here'
+
+class R1(object):
+
+    def index(self):
+        return 'R1 here'
+
+    def action(self):
+        return 'R done'
+
+    def __init__(self, request):
+        pass
+
+    implements(IV)
+
+class RZMI(R1):
+    pass



More information about the Zope3-Checkins mailing list