[Checkins] SVN: zope.componentvocabulary/trunk/ Merge vocabulary functionality from zope.app.testing into vocabulary,

Martijn Faassen faassen at startifact.com
Tue May 19 16:15:33 EDT 2009


Log message for revision 100139:
  Merge vocabulary functionality from zope.app.testing into vocabulary,
  and remove everything else that was taken from zope.app.component.
  

Changed:
  U   zope.componentvocabulary/trunk/CHANGES.txt
  U   zope.componentvocabulary/trunk/README.txt
  U   zope.componentvocabulary/trunk/buildout.cfg
  U   zope.componentvocabulary/trunk/setup.py
  D   zope.componentvocabulary/trunk/src/zope/app/
  A   zope.componentvocabulary/trunk/src/zope/componentvocabulary/
  U   zope.componentvocabulary/trunk/src/zope/componentvocabulary/__init__.py
  D   zope.componentvocabulary/trunk/src/zope/componentvocabulary/browser/
  U   zope.componentvocabulary/trunk/src/zope/componentvocabulary/configure.zcml
  D   zope.componentvocabulary/trunk/src/zope/componentvocabulary/contentdirective.py
  D   zope.componentvocabulary/trunk/src/zope/componentvocabulary/ftesting.zcml
  D   zope.componentvocabulary/trunk/src/zope/componentvocabulary/hooks.py
  D   zope.componentvocabulary/trunk/src/zope/componentvocabulary/interfaces/
  D   zope.componentvocabulary/trunk/src/zope/componentvocabulary/meta.zcml
  D   zope.componentvocabulary/trunk/src/zope/componentvocabulary/metaconfigure.py
  D   zope.componentvocabulary/trunk/src/zope/componentvocabulary/metadirectives.py
  D   zope.componentvocabulary/trunk/src/zope/componentvocabulary/site.py
  D   zope.componentvocabulary/trunk/src/zope/componentvocabulary/testing.py
  D   zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/adapter.py
  D   zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/components.py
  D   zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/exampleclass.py
  D   zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/factory.py
  D   zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/gen3.fs
  D   zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/module.py
  D   zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/test_directives.py
  U   zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/test_vocabulary.py
  D   zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/views.py
  U   zope.componentvocabulary/trunk/src/zope/componentvocabulary/vocabulary.py

-=-
Modified: zope.componentvocabulary/trunk/CHANGES.txt
===================================================================
--- zope.componentvocabulary/trunk/CHANGES.txt	2009-05-19 19:51:39 UTC (rev 100138)
+++ zope.componentvocabulary/trunk/CHANGES.txt	2009-05-19 20:15:33 UTC (rev 100139)
@@ -2,81 +2,8 @@
 CHANGES
 =======
 
-3.8.0 (unreleased)
-------------------
+1.0 (unreleased)
+----------------
 
-* zope.app.security was only a testing dependency so made it such.
-
-3.7.0 (2009-04-01)
-------------------
-
-- Removed deprecated `zope:defaultView` directive and its
-  implementation.  New directive to set default view is
-  `browser:defaultView`.
-
-3.6.1 (2009-03-12)
-------------------
-
-- Make ``class`` directive schemas importable from old location,
-  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.
-
-- Change package's mailing list address to zope-dev at zope.org,
-  because zope3-dev at zope.org is now retired.
-
-- Adapt to the move of IDefaultViewName from zope.component.interfaces
-  to zope.publisher.interfaces.
-
-3.6.0 (2009-01-31)
-------------------
-
-- Moved the implementation of the <class> directive from this package to
-  `zope.security`.  In particular, the module
-  `zope.app.component.contentdirective` has moved to
-  `zope.security.metaconfigure`, and a compatibility import has been
-  left in its place.
-
-- Extracted `zope.site` from zope.app.component with backwards
-  compatibility imports in place. Local site related functionality
-  is now in `zope.site` and packages should import from there.
-
-- Remove more deprecated on 3.5 code:
-
-  * zope.app.component.fields module that was pointing to the
-    removed back35's LayerField.
-  * zope.app.component.interface module that was moved to
-    zope.component.interface ages ago.
-  * zope:content and zope:localUtility directives.
-  * zope:factory directive.
-  * deprecated imports in zope.component.metaconfigure
-  * browser:tool directive and all zope.component.browser
-    meta.zcml stuff.
-
-- Remove "back35" extras_require as it doesn't make
-  any sense now.
-
-- Remove zope.modulealias test dependency as it is
-  not used anywhere.
-
-- Deprecate ISite and IPossibleSite imports from
-  zope.app.component.interfaces. They were moved
-  to zope.location.interfaces ages ago. Fix imports
-  in zope.app.component itself.
-
-3.5.0 (2008-10-13)
-------------------
-
-- Remove deprecated code slated for removal on 3.5.
-
-3.4.1 (2007-10-31)
-------------------
-
-- Resolve ``ZopeSecurityPolicy`` deprecation warning.
-
-
-3.4.0 (2007-10-11)
-------------------
-
-- Initial release independent of the main Zope tree.
+* Initial public release, derived from zope.app.component and
+  zope.app.interface to replace them.

Modified: zope.componentvocabulary/trunk/README.txt
===================================================================
--- zope.componentvocabulary/trunk/README.txt	2009-05-19 19:51:39 UTC (rev 100138)
+++ zope.componentvocabulary/trunk/README.txt	2009-05-19 20:15:33 UTC (rev 100139)
@@ -1,2 +1 @@
-This package provides various ZCML directives (view, resource) and a
-user interface related to local component management.
+This package contains various vocabularies.

Modified: zope.componentvocabulary/trunk/buildout.cfg
===================================================================
--- zope.componentvocabulary/trunk/buildout.cfg	2009-05-19 19:51:39 UTC (rev 100138)
+++ zope.componentvocabulary/trunk/buildout.cfg	2009-05-19 20:15:33 UTC (rev 100139)
@@ -4,11 +4,11 @@
 
 [test]
 recipe = zc.recipe.testrunner
-eggs = zope.app.component [test]
+eggs = zope.componentvocabulary
 
 [coverage-test]
 recipe = zc.recipe.testrunner
-eggs = zope.app.component [test]
+eggs = zope.componentvocabulary 
 defaults = ['--coverage', '../../coverage']
 
 [coverage-report]

Modified: zope.componentvocabulary/trunk/setup.py
===================================================================
--- zope.componentvocabulary/trunk/setup.py	2009-05-19 19:51:39 UTC (rev 100138)
+++ zope.componentvocabulary/trunk/setup.py	2009-05-19 20:15:33 UTC (rev 100139)
@@ -21,20 +21,17 @@
 def read(*rnames):
     return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
 
-setup(name='zope.app.component',
-      version='3.7.1dev',
+setup(name='zope.componentvocabulary',
+      version='1.0',
       author='Zope Corporation and Contributors',
       author_email='zope-dev at zope.org',
-      description='Local Zope Component Support',
+      description='Component vocabularies',
       long_description=(
           read('README.txt')
           + '\n\n' +
-          'Detailed Documentation\n'
-          '**********************\n'
-          + '\n\n' +
           read('CHANGES.txt')
           ),
-      keywords="zope component architecture local",
+      keywords="zope component architecture vocabulary",
       classifiers=[
           'Development Status :: 5 - Production/Stable',
           'Environment :: Web Environment',
@@ -45,44 +42,17 @@
           'Operating System :: OS Independent',
           'Topic :: Internet :: WWW/HTTP',
           'Framework :: Zope3'],
-      url='http://pypi.python.org/pypi/zope.app.component',
+      url='http://pypi.python.org/pypi/zope.componentvocabulary',
       license='ZPL 2.1',
       packages=find_packages('src'),
       package_dir={'': 'src'},
-      namespace_packages=['zope', 'zope.app'],
-      extras_require=dict(
-          test=['zope.app.testing',
-                'zope.app.securitypolicy',
-                'zope.app.zcmlfiles',
-                'zope.app.schema',
-                'zope.testbrowser',
-                'zope.app.security',
-                ]),
+      namespace_packages=['zope'],
       install_requires=[
           'setuptools',
-          'zope.site',
-          'zope.annotation',
-          'zope.app.container',
-          'zope.app.interface',
-          'zope.app.pagetemplate',
-          'zope.cachedescriptors',
-          'zope.component [hook]',
-          'zope.configuration',
-          'zope.deferredimport',
-          'zope.deprecation',
-          'zope.event',
-          'zope.exceptions',
-          'zope.filerepresentation',
-          'zope.formlib',
           'zope.i18nmessageid',
           'zope.interface',
-          'zope.lifecycleevent',
-          'zope.location>3.4.0b1',
-          'zope.publisher>=3.6.0',
           'zope.schema',
           'zope.security',
-          'zope.traversing',
-          'ZODB3',
           ],
       include_package_data=True,
       zip_safe=False,

Modified: zope.componentvocabulary/trunk/src/zope/componentvocabulary/__init__.py
===================================================================
--- zope.componentvocabulary/trunk/src/zope/app/component/__init__.py	2009-05-19 19:14:48 UTC (rev 100131)
+++ zope.componentvocabulary/trunk/src/zope/componentvocabulary/__init__.py	2009-05-19 20:15:33 UTC (rev 100139)
@@ -11,51 +11,5 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""Local Component Architecture
-
-$Id$
+"""Component vocabularies.
 """
-__docformat__ = "reStructuredText"
-
-import zope.component
-import zope.deprecation
-
-from zope.site import getNextUtility, queryNextUtility # BBB
-
-_marker = object()
-
-# BBB: Deprecated on 9/26/2006
- at zope.deprecation.deprecate('''This function has been deprecated and will go
-away in Zope 3.6. There is no replacement for this function, since it does not
-make sense in light of registry bases anymore. If you are using this function
-to lookup the next utility, consider using get/queryNextUtility. Otherwise, it
-is suggested to iterate through the list of bases of a registry manually.''')
-def getNextSiteManager(context):
-    """Get the next site manager."""
-    sm = queryNextSiteManager(context, _marker)
-    if sm is _marker:
-        raise zope.component.interfaces.ComponentLookupError(
-              "No more site managers have been found.")
-    return sm
-
-
-# BBB: Deprecated on 9/26/2006
- at zope.deprecation.deprecate('''This function has been deprecated and will go
-away in Zope 3.6. There is no replacement for this function, since it does not
-make sense in light of registry bases anymore. If you are using this function
-to lookup the next utility, consider using get/queryNextUtility. Otherwise, it
-is suggested to iterate through the list of bases of a registry manually.''')
-def queryNextSiteManager(context, default=None):
-    """Get the next site manager.
-
-    If the site manager of the given context is the global site manager, then
-    `default` is returned.
-    """
-    sm = zope.component.getSiteManager(context)
-    if sm is zope.component.getGlobalSiteManager():
-        return default
-
-    bases = sm.__bases__
-    if not bases:
-        return zope.component.getGlobalSiteManager()
-    return bases[0]

Modified: zope.componentvocabulary/trunk/src/zope/componentvocabulary/configure.zcml
===================================================================
--- zope.componentvocabulary/trunk/src/zope/app/component/configure.zcml	2009-05-19 19:14:48 UTC (rev 100131)
+++ zope.componentvocabulary/trunk/src/zope/componentvocabulary/configure.zcml	2009-05-19 20:15:33 UTC (rev 100139)
@@ -1,7 +1,5 @@
 <configure xmlns="http://namespaces.zope.org/zope">
 
-  <include package="zope.site" />
-
   <!-- the 'Interfaces' vocabulary below requires a registred IInterface --> 	 
   <interface 	 
       interface="zope.interface.interfaces.IInterface" 	 
@@ -12,6 +10,11 @@
       component=".vocabulary.InterfacesVocabulary" 	 
       name="Interfaces" 	 
       /> 	 
+
+  <utility
+      component=".vocabulary.ObjectInterfacesVocabulary"
+      name="Object Interfaces"
+      />
   	 
   <utility 	 
       component=".vocabulary.UtilityComponentInterfacesVocabulary" 	 

Deleted: zope.componentvocabulary/trunk/src/zope/componentvocabulary/contentdirective.py
===================================================================
--- zope.componentvocabulary/trunk/src/zope/app/component/contentdirective.py	2009-05-19 19:14:48 UTC (rev 100131)
+++ zope.componentvocabulary/trunk/src/zope/componentvocabulary/contentdirective.py	2009-05-19 20:15:33 UTC (rev 100139)
@@ -1,28 +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.
-#
-##############################################################################
-"""Backwards compatibility: moved this module to
-`zope.security.metaconfigure`.
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-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.componentvocabulary/trunk/src/zope/componentvocabulary/ftesting.zcml
===================================================================
--- zope.componentvocabulary/trunk/src/zope/app/component/ftesting.zcml	2009-05-19 19:14:48 UTC (rev 100131)
+++ zope.componentvocabulary/trunk/src/zope/componentvocabulary/ftesting.zcml	2009-05-19 20:15:33 UTC (rev 100139)
@@ -1,41 +0,0 @@
-<configure
-   xmlns="http://namespaces.zope.org/zope"
-   i18n_domain="zope"
-   package="zope.app.component"
-   >
-
-  <!-- This file is the equivalent of site.zcml and it is -->
-  <!-- used for functional testing setup -->
-
-  <include package="zope.securitypolicy" file="meta.zcml" />
-
-  <include package="zope.app.zcmlfiles" />
-  <include package="zope.app.authentication" />
-  <include package="zope.app.securitypolicy" />
-  <include package="zope.formlib" />
-
-  <securityPolicy
-      component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy" />
-
-  <role id="zope.Manager" title="Site Manager" />
-
-  <grantAll role="zope.Manager" />
-  <include package="zope.app.securitypolicy.browser.tests" file="functional.zcml" />
-
-  <!-- Principal that tests generally run as -->
-  <principal
-      id="zope.mgr"
-      title="Manager"
-      login="mgr"
-      password="mgrpw" />
-
-  <!-- Bootstrap principal used to make local grant to the principal above -->
-  <principal
-      id="zope.globalmgr"
-      title="Manager"
-      login="globalmgr"
-      password="globalmgrpw" />
-
-  <grant role="zope.Manager" principal="zope.globalmgr" />
-
-</configure>

Deleted: zope.componentvocabulary/trunk/src/zope/componentvocabulary/hooks.py
===================================================================
--- zope.componentvocabulary/trunk/src/zope/app/component/hooks.py	2009-05-19 19:14:48 UTC (rev 100131)
+++ zope.componentvocabulary/trunk/src/zope/componentvocabulary/hooks.py	2009-05-19 20:15:33 UTC (rev 100139)
@@ -1,33 +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.
-#
-##############################################################################
-"""This module here is for backwards compatibility.
-
-The real public API is now zope.site.hooks
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-from zope.site.hooks import (read_property,
-                             SiteInfo,
-                             siteinfo,
-                             setSite,
-                             getSite,
-                             getSiteManager,
-                             adapter_hook,
-                             setHooks,
-                             resetHooks,
-                             setSite,
-                             clearSite) # BBB
-                             

Deleted: zope.componentvocabulary/trunk/src/zope/componentvocabulary/meta.zcml
===================================================================
--- zope.componentvocabulary/trunk/src/zope/app/component/meta.zcml	2009-05-19 19:14:48 UTC (rev 100131)
+++ zope.componentvocabulary/trunk/src/zope/componentvocabulary/meta.zcml	2009-05-19 20:15:33 UTC (rev 100139)
@@ -1,27 +0,0 @@
-<configure
-    xmlns="http://namespaces.zope.org/zope"
-    xmlns:meta="http://namespaces.zope.org/meta">
-
-  <include package="zope.component" file="meta.zcml" />
-
-  <!-- BBB this include is for backwards-compatibility after directives were
-       moved from here. -->
-  <include package="zope.security" file="meta.zcml" />
-
-  <meta:directives namespace="http://namespaces.zope.org/zope">
-
-    <meta:directive
-        name="view"
-        schema=".metadirectives.IViewDirective"
-        handler="zope.app.component.metaconfigure.view"
-        />
-
-    <meta:directive
-        name="resource"
-        schema=".metadirectives.IResourceDirective"
-        handler="zope.app.component.metaconfigure.resource"
-        />
-
-  </meta:directives>
-
-</configure>

Deleted: zope.componentvocabulary/trunk/src/zope/componentvocabulary/metaconfigure.py
===================================================================
--- zope.componentvocabulary/trunk/src/zope/app/component/metaconfigure.py	2009-05-19 19:14:48 UTC (rev 100131)
+++ zope.componentvocabulary/trunk/src/zope/componentvocabulary/metaconfigure.py	2009-05-19 20:15:33 UTC (rev 100139)
@@ -1,183 +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.
-#
-##############################################################################
-"""Generic Components ZCML Handlers
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-import warnings
-from zope.interface import Interface
-from zope.component.zcml import handler, proxify
-from zope.component.interface import provideInterface
-from zope.configuration.exceptions import ConfigurationError
-from zope.security.checker import CheckerPublic
-from zope.security.checker import Checker
-
-PublicPermission = 'zope.Public'
-
-def _checker(_context, permission, allowed_interface, allowed_attributes):
-    if (not allowed_attributes) and (not allowed_interface):
-        allowed_attributes = ["__call__"]
-
-    if permission == PublicPermission:
-        permission = CheckerPublic
-
-    require={}
-    if allowed_attributes:
-        for name in allowed_attributes:
-            require[name] = permission
-    if allowed_interface:
-        for i in allowed_interface:
-            for name in i.names(all=True):
-                require[name] = permission
-
-    checker = Checker(require)
-    return checker
-
-def resource(_context, factory, type, name, layer=None,
-             permission=None,
-             allowed_interface=None, allowed_attributes=None,
-             provides=Interface):
-
-    if ((allowed_attributes or allowed_interface)
-        and (not permission)):
-        raise ConfigurationError(
-            "Must use name attribute with allowed_interface or "
-            "allowed_attributes"
-            )
-
-    if permission:
-        checker = _checker(_context, permission,
-                           allowed_interface, allowed_attributes)
-
-        def proxyResource(request, factory=factory, checker=checker):
-            return proxify(factory(request), checker)
-
-        factory = proxyResource
-
-    if layer is not None:
-        warnings.warn_explicit(
-            "The 'layer' argument of the 'resource' directive has been "
-            "deprecated.  Use the 'type' argument instead.",
-            DeprecationWarning, _context.info.file, _context.info.line)
-        type = layer
-
-    _context.action(
-        discriminator = ('resource', name, type, provides),
-        callable = handler,
-        args = ('registerAdapter',
-                factory, (type,), provides, name, _context.info),
-        )
-    _context.action(
-        discriminator = None,
-        callable = provideInterface,
-        args = (type.__module__ + '.' + type.__name__, type)
-               )
-    _context.action(
-        discriminator = None,
-        callable = provideInterface,
-        args = (provides.__module__ + '.' + provides.__name__, type)
-               )
-
-def view(_context, factory, type, name, for_, layer=None,
-         permission=None, allowed_interface=None, allowed_attributes=None,
-         provides=Interface):
-
-    if ((allowed_attributes or allowed_interface)
-        and (not permission)):
-        raise ConfigurationError(
-            "Must use name attribute with allowed_interface or "
-            "allowed_attributes"
-            )
-
-    if not factory:
-        raise ConfigurationError("No view factory specified.")
-
-    if permission:
-
-        checker = _checker(_context, permission,
-                           allowed_interface, allowed_attributes)
-
-        class ProxyView(object):
-            """Class to create simple proxy views."""
-
-            def __init__(self, factory, checker):
-                self.factory = factory
-                self.checker = checker
-
-            def __call__(self, *objects):
-                return proxify(self.factory(*objects), self.checker)
-
-        factory[-1] = ProxyView(factory[-1], checker)
-
-
-    if not for_:
-        raise ValueError("No for interfaces specified");
-    for_ = tuple(for_)
-
-    # Generate a single factory from multiple factories:
-    factories = factory
-    if len(factories) == 1:
-        factory = factories[0]
-    elif len(factories) < 1:
-        raise ValueError("No factory specified")
-    elif len(factories) > 1 and len(for_) > 1:
-        raise ValueError("Can't use multiple factories and multiple for")
-    else:
-        def factory(ob, request):
-            for f in factories[:-1]:
-                ob = f(ob)
-            return factories[-1](ob, request)
-
-    # BBB 2006/02/18, to be removed after 12 months
-    if layer is not None:
-        for_ = for_ + (layer,)
-        warnings.warn_explicit(
-            "The 'layer' argument of the 'view' directive has been "
-            "deprecated.  Use the 'type' argument instead. If you have "
-            "an existing 'type' argument IBrowserRequest, replace it with the "
-            "'layer' argument (the layer subclasses IBrowserRequest). "
-            "which subclasses BrowserRequest.",
-            DeprecationWarning, _context.info.file, _context.info.line)
-    else:
-        for_ = for_ + (type,)
-
-    _context.action(
-        discriminator = ('view', for_, name, provides),
-        callable = handler,
-        args = ('registerAdapter',
-                factory, for_, provides, name, _context.info),
-        )
-    if type is not None:
-        _context.action(
-            discriminator = None,
-            callable = provideInterface,
-            args = ('', type)
-            )
-
-    _context.action(
-        discriminator = None,
-        callable = provideInterface,
-        args = ('', provides)
-        )
-
-    if for_ is not None:
-        for iface in for_:
-            if iface is not None:
-                _context.action(
-                    discriminator = None,
-                    callable = provideInterface,
-                    args = ('', iface)
-                    )

Deleted: zope.componentvocabulary/trunk/src/zope/componentvocabulary/metadirectives.py
===================================================================
--- zope.componentvocabulary/trunk/src/zope/app/component/metadirectives.py	2009-05-19 19:14:48 UTC (rev 100131)
+++ zope.componentvocabulary/trunk/src/zope/componentvocabulary/metadirectives.py	2009-05-19 20:15:33 UTC (rev 100139)
@@ -1,161 +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.
-#
-##############################################################################
-"""Component architecture related 'zope' ZCML namespace directive interfaces
-
-$Id$
-"""
-__docformat__ = 'restructuredtext'
-
-import zope.configuration.fields
-import zope.deferredimport
-import zope.security.zcml
-import zope.interface
-import zope.schema
-from zope.component.zcml import IBasicComponentInformation
-
-from zope.app.component.i18n import ZopeMessageFactory as _
-
-# BBB
-zope.deferredimport.deprecatedFrom(
-    "Schemas for the ``class`` directive and its subdirectives are now "
-    "moved to zope.security.metadirectives. Imports from here are "
-    "deprecated and will be removed in Zope 3.6",
-
-    'zope.security.metadirectives',
-
-    'IClassDirective',
-    'IImplementsSubdirective',
-    'IRequireSubdirective',
-    'IAllowSubdirective',
-    'IFactorySubdirective',
-)
-
-class IBasicViewInformation(zope.interface.Interface):
-    """This is the basic information for all views."""
-
-    for_ = zope.configuration.fields.Tokens(
-        title=_("Specifications of the objects to be viewed"),
-        description=_("""This should be a list of interfaces or classes
-        """),
-        required=True,
-        value_type=zope.configuration.fields.GlobalObject(
-          missing_value=object(),
-          ),
-        )
-
-    permission = zope.security.zcml.Permission(
-        title=_("Permission"),
-        description=_("The permission needed to use the view."),
-        required=False,
-        )
-
-    class_ = zope.configuration.fields.GlobalObject(
-        title=_("Class"),
-        description=_("A class that provides attributes used by the view."),
-        required=False,
-        )
-
-    layer = zope.configuration.fields.GlobalInterface(
-        title=_("The layer the view is in."),
-        description=_("""
-        A skin is composed of layers. It is common to put skin
-        specific views in a layer named after the skin. If the 'layer'
-        attribute is not supplied, it defaults to 'default'."""),
-        required=False,
-        )
-
-    allowed_interface = zope.configuration.fields.Tokens(
-        title=_("Interface that is also allowed if user has permission."),
-        description=_("""
-        By default, 'permission' only applies to viewing the view and
-        any possible sub views. By specifying this attribute, you can
-        make the permission also apply to everything described in the
-        supplied interface.
-
-        Multiple interfaces can be provided, separated by
-        whitespace."""),
-        required=False,
-        value_type=zope.configuration.fields.GlobalInterface(),
-        )
-
-    allowed_attributes = zope.configuration.fields.Tokens(
-        title=_("View attributes that are also allowed if the user"
-                " has permission."),
-        description=_("""
-        By default, 'permission' only applies to viewing the view and
-        any possible sub views. By specifying 'allowed_attributes',
-        you can make the permission also apply to the extra attributes
-        on the view object."""),
-        required=False,
-        value_type=zope.configuration.fields.PythonIdentifier(),
-        )
-
-class IBasicResourceInformation(zope.interface.Interface):
-    """
-    Basic information for resources
-    """
-
-    name = zope.schema.TextLine(
-        title=_("The name of the resource."),
-        description=_("The name shows up in URLs/paths. For example 'foo'."),
-        required=True,
-        default=u'',
-        )
-
-    provides = zope.configuration.fields.GlobalInterface(
-        title=_("The interface this component provides."),
-        description=_("""
-        A view can provide an interface.  This would be used for
-        views that support other views."""),
-        required=False,
-        default=zope.interface.Interface,
-        )
-
-    type = zope.configuration.fields.GlobalInterface(
-        title=_("Request type"),
-        required=True
-        )
-
-
-class IViewDirective(IBasicViewInformation, IBasicResourceInformation):
-    """Register a view for a component"""
-
-    factory = zope.configuration.fields.Tokens(
-        title=_("Factory"),
-        required=False,
-        value_type=zope.configuration.fields.GlobalObject(),
-        )
-
-
-class IResourceDirective(IBasicComponentInformation,
-                         IBasicResourceInformation):
-    """Register a resource"""
-
-    layer = zope.configuration.fields.GlobalInterface(
-        title=_("The layer the resource is in."),
-        required=False,
-        )
-
-    allowed_interface = zope.configuration.fields.Tokens(
-        title=_("Interface that is also allowed if user has permission."),
-        required=False,
-        value_type=zope.configuration.fields.GlobalInterface(),
-        )
-
-    allowed_attributes = zope.configuration.fields.Tokens(
-        title=_("View attributes that are also allowed if user"
-                " has permission."),
-        required=False,
-        value_type=zope.configuration.fields.PythonIdentifier(),
-        )

Deleted: zope.componentvocabulary/trunk/src/zope/componentvocabulary/site.py
===================================================================
--- zope.componentvocabulary/trunk/src/zope/app/component/site.py	2009-05-19 19:14:48 UTC (rev 100131)
+++ zope.componentvocabulary/trunk/src/zope/componentvocabulary/site.py	2009-05-19 20:15:33 UTC (rev 100139)
@@ -1,33 +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.
-#
-##############################################################################
-"""This module here is for backwards compatibility.
-
-The real public API is now zope.site
-
-$Id$
-"""
-# on the side of caution for backwards compatibility we
-# import everything defined
-from zope.site.site import (SiteManagementFolder,
-                            SMFolderFactory,
-                            SiteManagerContainer,
-                            _findNextSiteManager,
-                            _LocalAdapterRegistry,
-                            LocalSiteManager,
-                            threadSiteSubscriber,
-                            clearThreadSiteSubscriber,
-                            setSite,
-                            clearSite,
-                            SiteManagerAdapter,
-                            changeSiteConfigurationAfterMove) # BBB

Deleted: zope.componentvocabulary/trunk/src/zope/componentvocabulary/testing.py
===================================================================
--- zope.componentvocabulary/trunk/src/zope/app/component/testing.py	2009-05-19 19:14:48 UTC (rev 100131)
+++ zope.componentvocabulary/trunk/src/zope/componentvocabulary/testing.py	2009-05-19 20:15:33 UTC (rev 100139)
@@ -1,197 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2001-2007 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.
-#
-##############################################################################
-"""Base Mix-in class for Placeful Setups
-
-Also contains common test related classes/functions/objects.
-
-$Id$
-"""
-
-import os
-import zope.interface
-import zope.site.folder
-from zope.component.interfaces import IComponentLookup
-from zope.app.component.interfaces import ILocalSiteManager
-from zope.app.testing import setup
-from zope.app.testing.placelesssetup import PlacelessSetup
-
-from zope.app.testing.functional import ZCMLLayer
-from zope.traversing.api import traverse
-
-AppComponentLayer = ZCMLLayer(
-    os.path.join(os.path.split(__file__)[0], 'ftesting.zcml'),
-    __name__, 'AppComponentLayer', allow_teardown=True)
-
-class Place(object):
-
-    def __init__(self, path):
-        self.path = path
-
-    def __get__(self, inst, cls=None):
-        if inst is None:
-            return self
-
-        try:
-            # Use __dict__ directly to avoid infinite recursion
-            root = inst.__dict__['rootFolder']
-        except KeyError:
-            root = inst.rootFolder = setup.buildSampleFolderTree()
-
-        return traverse(root, self.path)
-
-
-class PlacefulSetup(PlacelessSetup):
-
-    # Places :)
-    rootFolder  = Place(u'')
-
-    folder1     = Place(u'folder1')
-    folder1_1   = Place(u'folder1/folder1_1')
-    folder1_1_1 = Place(u'folder1/folder1_1/folder1_1_1')
-    folder1_1_2 = Place(u'folder1/folder1_2/folder1_1_2')
-    folder1_2   = Place(u'folder1/folder1_2')
-    folder1_2_1 = Place(u'folder1/folder1_2/folder1_2_1')
-
-    folder2     = Place(u'folder2')
-    folder2_1   = Place(u'folder2/folder2_1')
-    folder2_1_1 = Place(u'folder2/folder2_1/folder2_1_1')
-
-    folder3     = Place(u"\N{CYRILLIC SMALL LETTER PE}"
-                        u"\N{CYRILLIC SMALL LETTER A}"
-                        u"\N{CYRILLIC SMALL LETTER PE}"
-                        u"\N{CYRILLIC SMALL LETTER KA}"
-                        u"\N{CYRILLIC SMALL LETTER A}3")
-    folder3_1   = Place(u"\N{CYRILLIC SMALL LETTER PE}"
-                        u"\N{CYRILLIC SMALL LETTER A}"
-                        u"\N{CYRILLIC SMALL LETTER PE}"
-                        u"\N{CYRILLIC SMALL LETTER KA}"
-                        u"\N{CYRILLIC SMALL LETTER A}3/"
-                        u"\N{CYRILLIC SMALL LETTER PE}"
-                        u"\N{CYRILLIC SMALL LETTER A}"
-                        u"\N{CYRILLIC SMALL LETTER PE}"
-                        u"\N{CYRILLIC SMALL LETTER KA}"
-                        u"\N{CYRILLIC SMALL LETTER A}3_1")
-
-    def setUp(self, folders=False, site=False):
-        setup.placefulSetUp()
-        if folders or site:
-            return self.buildFolders(site)
-
-    def tearDown(self):
-        setup.placefulTearDown()
-        # clean up folders and placeful site managers and services too?
-
-    def buildFolders(self, site=False):
-        self.rootFolder = setup.buildSampleFolderTree()
-        if site:
-            return self.makeSite()
-
-    def makeSite(self, path='/'):
-        folder = traverse(self.rootFolder, path)
-        return setup.createSiteManager(folder, True)
-
-    def createRootFolder(self):
-        self.rootFolder = zope.site.folder.rootFolder()
-
-
-class SiteManagerStub(object):
-    zope.interface.implements(ILocalSiteManager)
-
-    __bases__ = ()
-
-    def __init__(self):
-        self._utils = {}
-
-    def setNext(self, next):
-        self.__bases__ = (next, )
-
-    def provideUtility(self, iface, util, name=''):
-        self._utils[(iface, name)] = util
-
-    def queryUtility(self, iface, name='', default=None):
-        return self._utils.get((iface, name), default)
-    
-
-def testingNextUtility(utility, nextutility, interface, name='',
-                       sitemanager=None, nextsitemanager=None):
-    """Provide a next utility for testing.
-
-    Since utilities must be registered in sites, we really provide a next
-    site manager in which we place the next utility. If you do not pass in
-    any site managers, they will be created for you.
-
-    For a simple usage of this function, see the doc test of
-    `queryNextUtility()`. Here is a demonstration that passes in the services
-    directly and ensures that the `__parent__` attributes are set correctly.
-
-    First, we need to create a utility interface and implementation:
-
-      >>> from zope.interface import Interface, implements
-      >>> class IAnyUtility(Interface):
-      ...     pass
-      
-      >>> class AnyUtility(object):
-      ...     implements(IAnyUtility)
-      ...     def __init__(self, id):
-      ...         self.id = id
-      
-      >>> any1 = AnyUtility(1)
-      >>> any1next = AnyUtility(2)
-
-    Now we create a special site manager that can have a location:
-
-      >>> SiteManager = type('SiteManager', (GlobalSiteManager,),
-      ...                       {'__parent__': None})
-
-    Let's now create one site manager
-
-      >>> sm = SiteManager()
-
-    and pass it in as the original site manager to the function:
-
-      >>> testingNextUtility(any1, any1next, IAnyUtility, sitemanager=sm)
-      >>> any1.__parent__ is utils
-      True
-      >>> smnext = any1next.__parent__
-      >>> sm.__parent__.next.data['Utilities'] is smnext
-      True
-
-    or if we pass the current and the next site manager:
-
-      >>> sm = SiteManager()
-      >>> smnext = SiteManager()
-      >>> testingNextUtility(any1, any1next, IAnyUtility,
-      ...                    sitemanager=sm, nextsitemanager=smnext)
-      >>> any1.__parent__ is sm
-      True
-      >>> any1next.__parent__ is smnext
-      True
-    
-    """
-    if sitemanager is None:
-        sitemanager = SiteManagerStub()
-    if nextsitemanager is None:
-        nextsitemanager = SiteManagerStub()
-    sitemanager.setNext(nextsitemanager)
-
-    sitemanager.provideUtility(interface, utility, name)
-    utility.__conform__ = (
-        lambda iface:
-        iface.isOrExtends(IComponentLookup) and sitemanager or None
-        )
-    nextsitemanager.provideUtility(interface, nextutility, name)
-    nextutility.__conform__ = (
-        lambda iface:
-        iface.isOrExtends(IComponentLookup) and nextsitemanager or None
-        )

Deleted: zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/adapter.py
===================================================================
--- zope.componentvocabulary/trunk/src/zope/app/component/tests/adapter.py	2009-05-19 19:14:48 UTC (rev 100131)
+++ zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/adapter.py	2009-05-19 20:15:33 UTC (rev 100139)
@@ -1,63 +0,0 @@
-##############################################################################
-#
-# 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 29080 2005-02-08 00:07:11Z jim $
-"""
-import zope.interface
-import zope.component
-import components
-
-class I1(zope.interface.Interface):
-    pass
-
-class I2(zope.interface.Interface):
-    pass
-
-class I3(zope.interface.Interface):
-    def f1(): pass
-    def f2(): pass
-    def f3(): 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.component.adapts(components.IContent, I1, I2)
-    zope.interface.implements(I3)
-
-class A4:
-    pass
-
-a4 = A4()
-
-class A5:
-    zope.interface.implements(I1, I2)
-
-a5 = A5()
-
-def Handler(content, *args):
-    # uninteresting handler
-    content.args = getattr(content, 'args', ()) + (args, )

Deleted: zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/components.py
===================================================================
--- zope.componentvocabulary/trunk/src/zope/app/component/tests/components.py	2009-05-19 19:14:48 UTC (rev 100131)
+++ zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/components.py	2009-05-19 20:15:33 UTC (rev 100139)
@@ -1,44 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 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.
-#
-##############################################################################
-"""Components for testing
-
-$Id$
-"""
-from zope.interface import Interface, Attribute, implements
-from zope.component import adapts
-
-class IAppb(Interface):
-    a = Attribute('test attribute')
-    def f(): "test func"
-
-class IApp(IAppb):
-    pass
-
-class IContent(Interface): pass
-
-class Content(object):
-    implements(IContent)
-
-class Comp(object):
-    adapts(IContent)
-    implements(IApp)
-
-    def __init__(self, *args):
-        # Ignore arguments passed to constructor
-        pass
-
-    a = 1
-    def f(): pass
-
-comp = Comp()

Deleted: zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/exampleclass.py
===================================================================
--- zope.componentvocabulary/trunk/src/zope/app/component/tests/exampleclass.py	2009-05-19 19:14:48 UTC (rev 100131)
+++ zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/exampleclass.py	2009-05-19 20:15:33 UTC (rev 100139)
@@ -1,30 +0,0 @@
-##############################################################################
-#
-# 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

Deleted: zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/factory.py
===================================================================
--- zope.componentvocabulary/trunk/src/zope/app/component/tests/factory.py	2009-05-19 19:14:48 UTC (rev 100131)
+++ zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/factory.py	2009-05-19 20:15:33 UTC (rev 100139)
@@ -1,44 +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.
-#
-##############################################################################
-"""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)

Deleted: zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/gen3.fs
===================================================================
(Binary files differ)

Deleted: zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/module.py
===================================================================
--- zope.componentvocabulary/trunk/src/zope/app/component/tests/module.py	2009-05-19 19:14:48 UTC (rev 100131)
+++ zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/module.py	2009-05-19 20:15:33 UTC (rev 100139)
@@ -1,58 +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.
-#
-##############################################################################
-"""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>"""

Deleted: zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/test_directives.py
===================================================================
--- zope.componentvocabulary/trunk/src/zope/app/component/tests/test_directives.py	2009-05-19 19:14:48 UTC (rev 100131)
+++ zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/test_directives.py	2009-05-19 20:15:33 UTC (rev 100139)
@@ -1,782 +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.
-#
-##############################################################################
-"""Component Directives Tests
-
-$Id$
-"""
-import re
-import unittest
-import pprint
-import warnings
-from cStringIO import StringIO
-
-import zope.component
-from zope.interface import implements
-from zope.testing.doctestunit import DocTestSuite
-from zope.component.interfaces import ComponentLookupError
-from zope.component.interface import queryInterface
-from zope.publisher.interfaces import IDefaultViewName
-
-from zope.configuration.xmlconfig import xmlconfig, XMLConfig
-from zope.configuration.exceptions import ConfigurationError
-from zope.configuration.xmlconfig import ZopeXMLConfigurationError
-from zope.security.checker import ProxyFactory, selectChecker
-from zope.security import proxy
-
-import zope.app.component
-from zope.app.testing.placelesssetup import PlacelessSetup
-from zope.app.component.tests.adapter import A1, A2, A3
-from zope.app.component.tests.adapter import I1, I2, I3, IS
-from zope.app.component.tests.components import IContent, Content
-from zope.app.component.tests.components import IApp
-from zope.app.component.tests.views import Request, IV, IC, V1, R1, IR
-
-from zope.app.component.tests import module, exampleclass
-
-# TODO: tests for other directives needed
-
-atre = re.compile(' at [0-9a-fA-Fx]+')
-
-class Context(object):
-    actions = ()
-
-    def action(self, discriminator, callable, args):
-        self.actions += ((discriminator, callable, args), )
-
-    def __repr__(self):
-        stream = StringIO()
-        pprinter = pprint.PrettyPrinter(stream=stream, width=60)
-        pprinter.pprint(self.actions)
-        r = stream.getvalue()
-        return (''.join(atre.split(r))).strip()
-
-
-template = """<configure
-   xmlns='http://namespaces.zope.org/zope'
-   xmlns:test='http://www.zope.org/NS/Zope3/test'
-   i18n_domain='zope'>
-   %s
-   </configure>"""
-
-class Ob(object):
-    implements(IC)
-
-def definePermissions():
-    XMLConfig('meta.zcml', zope.app.component)()
-
-
-class Test(PlacelessSetup, unittest.TestCase):
-
-    def setUp(self):
-        super(Test, self).setUp()
-        XMLConfig('meta.zcml', zope.app.component)()
-        XMLConfig('meta.zcml', zope.app.security)()
-
-    def testView(self):
-        ob = Ob()
-        request = Request(IV)
-        self.assertEqual(
-            zope.component.queryMultiAdapter((ob, request), name=u'test'), None)
-
-        xmlconfig(StringIO(template %
-            '''
-            <view name="test"
-                  factory="zope.app.component.tests.views.V1"
-                  for="zope.app.component.tests.views.IC"
-                  type="zope.app.component.tests.views.IV"/>
-            '''
-            ))
-
-        self.assertEqual(
-            zope.component.queryMultiAdapter((ob, request),
-                                             name=u'test').__class__,
-            V1)
-
-
-    def testMultiView(self):
-        xmlconfig(StringIO(template %
-            '''
-            <view name="test"
-                  factory="zope.app.component.tests.adapter.A3"
-                  for="zope.app.component.tests.views.IC
-                       zope.app.component.tests.adapter.I1
-                       zope.app.component.tests.adapter.I2"
-                  type="zope.app.component.tests.views.IV"/>
-            '''
-            ))
-
-
-        ob = Ob()
-        a1 = A1()
-        a2 = A2()
-        request = Request(IV)
-        view = zope.component.queryMultiAdapter((ob, a1, a2, request),
-                                                name=u'test')
-        self.assertEqual(view.__class__, A3)
-        self.assertEqual(view.context, (ob, a1, a2, request))
-
-
-    def testMultiView_fails_w_multiple_factories(self):
-        self.assertRaises(
-            ConfigurationError,
-            xmlconfig,
-            StringIO(template %
-              '''
-              <view name="test"
-                    factory="zope.app.component.tests.adapter.A3
-                             zope.app.component.tests.adapter.A2"
-                    for="zope.app.component.tests.views.IC
-                         zope.app.component.tests.adapter.I1
-                         zope.app.component.tests.adapter.I2"
-                    type="zope.app.component.tests.views.IV"/>
-              '''
-              )
-            )
-
-    def testView_w_multiple_factories(self):
-        xmlconfig(StringIO(template %
-            '''
-            <view name="test"
-                  factory="zope.app.component.tests.adapter.A1
-                           zope.app.component.tests.adapter.A2
-                           zope.app.component.tests.adapter.A3
-                           zope.app.component.tests.views.V1"
-                  for="zope.app.component.tests.views.IC"
-                  type="zope.app.component.tests.views.IV"/>
-            '''
-            ))
-
-        ob = Ob()
-
-        # The view should be a V1 around an A3, around an A2, around
-        # an A1, anround ob:
-        view = zope.component.queryMultiAdapter((ob, Request(IV)), name=u'test')
-        self.assertEqual(view.__class__, V1)
-        a3 = view.context
-        self.assertEqual(a3.__class__, A3)
-        a2 = a3.context[0]
-        self.assertEqual(a2.__class__, A2)
-        a1 = a2.context[0]
-        self.assertEqual(a1.__class__, A1)
-        self.assertEqual(a1.context[0], ob)
-
-    def testView_fails_w_no_factories(self):
-        self.assertRaises(ConfigurationError,
-                          xmlconfig,
-                          StringIO(template %
-                                   '''
-                                   <view name="test"
-                                   factory=""
-                                   for="zope.app.component.tests.views.IC"
-                                   type="zope.app.component.tests.views.IV"/>
-                                   '''
-                                   ),
-                          )
-
-
-    def testViewThatProvidesAnInterface(self):
-        ob = Ob()
-        self.assertEqual(
-            zope.component.queryMultiAdapter((ob, Request(IR)), IV, u'test'),
-            None)
-
-        xmlconfig(StringIO(template %
-            '''
-            <view name="test"
-                  factory="zope.app.component.tests.views.V1"
-                  for="zope.app.component.tests.views.IC"
-                  type="zope.app.component.tests.views.IR"
-                  />
-            '''
-            ))
-
-        self.assertEqual(
-            zope.component.queryMultiAdapter((ob, Request(IR)), IV, u'test'),
-            None)
-
-        xmlconfig(StringIO(template %
-            '''
-            <view name="test"
-                  factory="zope.app.component.tests.views.V1"
-                  for="zope.app.component.tests.views.IC"
-                  type="zope.app.component.tests.views.IR"
-                  provides="zope.app.component.tests.views.IV"
-                  />
-            '''
-            ))
-
-        v = zope.component.queryMultiAdapter((ob, Request(IR)), IV, u'test')
-        self.assertEqual(v.__class__, V1)
-
-
-    def testUnnamedViewThatProvidesAnInterface(self):
-        ob = Ob()
-        self.assertEqual(
-            zope.component.queryMultiAdapter((ob, Request(IR)), IV), None)
-
-        xmlconfig(StringIO(template %
-            '''
-            <view factory="zope.app.component.tests.views.V1"
-                  for="zope.app.component.tests.views.IC"
-                  type="zope.app.component.tests.views.IR"
-                  />
-            '''
-            ))
-
-        v = zope.component.queryMultiAdapter((ob, Request(IR)), IV)
-        self.assertEqual(v, None)
-
-        xmlconfig(StringIO(template %
-            '''
-            <view factory="zope.app.component.tests.views.V1"
-                  for="zope.app.component.tests.views.IC"
-                  type="zope.app.component.tests.views.IR"
-                  provides="zope.app.component.tests.views.IV"
-                  />
-            '''
-            ))
-
-        v = zope.component.queryMultiAdapter((ob, Request(IR)), IV)
-        self.assertEqual(v.__class__, V1)
-
-    def testViewHavingARequiredClass(self):
-        xmlconfig(StringIO(template % (
-            '''
-            <view
-              for="zope.app.component.tests.components.Content"
-              type="zope.app.component.tests.views.IR"
-              factory="zope.app.component.tests.adapter.A1"
-              />
-            '''
-            )))
-
-        content = Content()
-        a1 = zope.component.getMultiAdapter((content, Request(IR)))
-        self.assert_(isinstance(a1, A1))
-
-        class MyContent:
-            implements(IContent)
-
-        self.assertRaises(ComponentLookupError, zope.component.getMultiAdapter,
-                          (MyContent(), Request(IR)))
-
-    def testInterfaceProtectedView(self):
-        xmlconfig(StringIO(template %
-            '''
-            <view name="test"
-                  factory="zope.app.component.tests.views.V1"
-                  for="zope.app.component.tests.views.IC"
-                  type="zope.app.component.tests.views.IV"
-                  permission="zope.Public"
-              allowed_interface="zope.app.component.tests.views.IV"
-                  />
-            '''
-            ))
-
-        v = ProxyFactory(zope.component.getMultiAdapter((Ob(), Request(IV)),
-                                                        name='test'))
-        self.assertEqual(v.index(), 'V1 here')
-        self.assertRaises(Exception, getattr, v, 'action')
-
-    def testAttributeProtectedView(self):
-        xmlconfig(StringIO(template %
-            '''
-            <view name="test"
-                  factory="zope.app.component.tests.views.V1"
-                  for="zope.app.component.tests.views.IC"
-                  type="zope.app.component.tests.views.IV"
-                  permission="zope.Public"
-                  allowed_attributes="action"
-                  />
-            '''
-            ))
-
-        v = ProxyFactory(zope.component.getMultiAdapter((Ob(), Request(IV)),
-                                                        name='test'))
-        self.assertEqual(v.action(), 'done')
-        self.assertRaises(Exception, getattr, v, 'index')
-
-    def testInterfaceAndAttributeProtectedView(self):
-        xmlconfig(StringIO(template %
-            '''
-            <view name="test"
-                  factory="zope.app.component.tests.views.V1"
-                  for="zope.app.component.tests.views.IC"
-                  type="zope.app.component.tests.views.IV"
-                  permission="zope.Public"
-                  allowed_attributes="action"
-              allowed_interface="zope.app.component.tests.views.IV"
-                  />
-            '''
-            ))
-
-        v = zope.component.getMultiAdapter((Ob(), Request(IV)), name='test')
-        self.assertEqual(v.index(), 'V1 here')
-        self.assertEqual(v.action(), 'done')
-
-    def testDuplicatedInterfaceAndAttributeProtectedView(self):
-        xmlconfig(StringIO(template %
-            '''
-            <view name="test"
-                  factory="zope.app.component.tests.views.V1"
-                  for="zope.app.component.tests.views.IC"
-                  type="zope.app.component.tests.views.IV"
-                  permission="zope.Public"
-                  allowed_attributes="action index"
-              allowed_interface="zope.app.component.tests.views.IV"
-                  />
-            '''
-            ))
-
-        v = zope.component.getMultiAdapter((Ob(), Request(IV)), name='test')
-        self.assertEqual(v.index(), 'V1 here')
-        self.assertEqual(v.action(), 'done')
-
-    def testIncompleteProtectedViewNoPermission(self):
-        self.assertRaises(
-            ConfigurationError,
-            xmlconfig,
-            StringIO(template %
-            '''
-            <view name="test"
-                  factory="zope.app.component.tests.views.V1"
-                  for="zope.app.component.tests.views.IC"
-                  type="zope.app.component.tests.views.IV"
-                  allowed_attributes="action index"
-                  />
-            '''
-            ))
-
-    def testViewUndefinedPermission(self):
-        config = StringIO(template % (
-            '''
-            <view name="test"
-                  factory="zope.app.component.tests.views.V1"
-                  for="zope.app.component.tests.views.IC"
-                  type="zope.app.component.tests.views.IV"
-                  permission="zope.UndefinedPermission"
-                  allowed_attributes="action index"
-              allowed_interface="zope.app.component.tests.views.IV"
-                  />
-            '''
-            ))
-        self.assertRaises(ValueError, xmlconfig, config, testing=1)
-
-    def testResource(self):
-        ob = Ob()
-        self.assertEqual(
-            zope.component.queryAdapter(Request(IV), name=u'test'), None)
-        xmlconfig(StringIO(template % (
-            '''
-            <resource name="test"
-                  factory="zope.app.component.tests.views.R1"
-                  type="zope.app.component.tests.views.IV"/>
-            '''
-            )))
-
-        self.assertEqual(
-            zope.component.queryAdapter(Request(IV), name=u'test').__class__,
-            R1)
-
-    def testResourceThatProvidesAnInterface(self):
-        ob = Ob()
-        self.assertEqual(zope.component.queryAdapter(Request(IR), IV, u'test'),
-                         None)
-
-        xmlconfig(StringIO(template %
-            '''
-            <resource
-                name="test"
-                factory="zope.app.component.tests.views.R1"
-                type="zope.app.component.tests.views.IR"
-                />
-            '''
-            ))
-
-        v = zope.component.queryAdapter(Request(IR), IV, name=u'test')
-        self.assertEqual(v, None)
-
-        xmlconfig(StringIO(template %
-            '''
-            <resource
-                name="test"
-                factory="zope.app.component.tests.views.R1"
-                type="zope.app.component.tests.views.IR"
-                provides="zope.app.component.tests.views.IV"
-                />
-            '''
-            ))
-
-        v = zope.component.queryAdapter(Request(IR), IV, name=u'test')
-        self.assertEqual(v.__class__, R1)
-
-    def testUnnamedResourceThatProvidesAnInterface(self):
-        ob = Ob()
-        self.assertEqual(zope.component.queryAdapter(Request(IR), IV), None)
-
-        xmlconfig(StringIO(template %
-            '''
-            <resource
-                factory="zope.app.component.tests.views.R1"
-                type="zope.app.component.tests.views.IR"
-                />
-            '''
-            ))
-
-        v = zope.component.queryAdapter(Request(IR), IV)
-        self.assertEqual(v, None)
-
-        xmlconfig(StringIO(template %
-            '''
-            <resource
-                factory="zope.app.component.tests.views.R1"
-                type="zope.app.component.tests.views.IR"
-                provides="zope.app.component.tests.views.IV"
-                />
-            '''
-            ))
-
-        v = zope.component.queryAdapter(Request(IR), IV)
-        self.assertEqual(v.__class__, R1)
-
-    def testResourceUndefinedPermission(self):
-
-        config = StringIO(template % (
-            '''
-            <resource name="test"
-                  factory="zope.app.component.tests.views.R1"
-                  type="zope.app.component.tests.views.IV"
-                  permission="zope.UndefinedPermission"/>
-            '''
-            ))
-        self.assertRaises(ValueError, xmlconfig, config, testing=1)
-
-
-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 TestFactoryDirective(PlacelessSetup, unittest.TestCase):
-    def setUp(self):
-        super(TestFactoryDirective, self).setUp()
-        XMLConfig('meta.zcml', zope.app.component)()
-        XMLConfig('meta.zcml', zope.app.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)
-        obj = zope.component.createObject('test.Example')
-        self.failUnless(proxy.isinstance(obj, exampleclass.ExampleClass))
-
-
-
-PREFIX = module.__name__ + '.'
-
-def defineDirectives():
-    XMLConfig('meta.zcml', zope.app.component)()
-    XMLConfig('meta.zcml', zope.app.security)()
-    xmlconfig(StringIO("""<configure
-        xmlns='http://namespaces.zope.org/zope'
-        i18n_domain='zope'>
-       <permission id="zope.Extravagant" title="extravagant" />
-       <permission id="zope.Paltry" title="paltry" />
-    </configure>"""))
-
-NOTSET = []
-
-P1 = "zope.Extravagant"
-P2 = "zope.Paltry"
-
-class TestRequireDirective(PlacelessSetup, unittest.TestCase):
-
-    def setUp(self):
-        super(TestRequireDirective, self).setUp()
-        defineDirectives()
-
-        class B(object):
-            def m1(self):
-                return "m1"
-            def m2(self):
-                return "m2"
-        class C(B):
-            implements(module.I)
-            def m3(self):
-                return "m3"
-            def m4(self):
-                return "m4"
-        module.test_base = B
-        module.test_class = C
-        module.test_instance = C()
-        self.assertState()
-
-    def tearDown(self):
-        PlacelessSetup.tearDown(self)
-        module.test_class = None
-
-    def assertState(self, m1P=NOTSET, m2P=NOTSET, m3P=NOTSET):
-        "Verify that class, instance, and methods have expected permissions."
-
-        from zope.security.checker import selectChecker
-
-        checker = selectChecker(module.test_instance)
-        self.assertEqual(checker.permission_id('m1'), (m1P or None))
-        self.assertEqual(checker.permission_id('m2'), (m2P or None))
-        self.assertEqual(checker.permission_id('m3'), (m3P or None))
-
-    def assertDeclaration(self, declaration, **state):
-        apply_declaration(module.template_bracket % declaration)
-        self.assertState(**state)
-
-    # "testSimple*" exercises tags that do NOT have children.  This mode
-    # inherently sets the instances as well as the class attributes.
-
-    def testSimpleMethodsPlural(self):
-        declaration = ('''<class class="%s">
-                            <require
-                                permission="%s"
-                                attributes="m1 m3"/>
-                          </class>'''
-                       % (PREFIX+"test_class", P1))
-        self.assertDeclaration(declaration, m1P=P1, m3P=P1)
-
-    def assertSetattrState(self, m1P=NOTSET, m2P=NOTSET, m3P=NOTSET):
-        "Verify that class, instance, and methods have expected permissions."
-
-        from zope.security.checker import selectChecker
-
-        checker = selectChecker(module.test_instance)
-        self.assertEqual(checker.setattr_permission_id('m1'), (m1P or None))
-        self.assertEqual(checker.setattr_permission_id('m2'), (m2P or None))
-        self.assertEqual(checker.setattr_permission_id('m3'), (m3P or None))
-
-    def assertSetattrDeclaration(self, declaration, **state):
-        self.assertSetattrState(**state)
-
-    def test_set_attributes(self):
-        declaration = ('''<class class="%s">
-                            <require
-                                permission="%s"
-                                set_attributes="m1 m3"/>
-                          </class>'''
-                       % (PREFIX+"test_class", P1))
-        apply_declaration(module.template_bracket % declaration)
-        checker = selectChecker(module.test_instance)
-        self.assertEqual(checker.setattr_permission_id('m1'), P1)
-        self.assertEqual(checker.setattr_permission_id('m2'), None)
-        self.assertEqual(checker.setattr_permission_id('m3'), P1)
-
-    def test_set_schema(self):
-
-        self.assertEqual(queryInterface(PREFIX+"S"), None)
-
-        declaration = ('''<class class="%s">
-                            <require
-                                permission="%s"
-                                set_schema="%s"/>
-                          </class>'''
-                       % (PREFIX+"test_class", P1, PREFIX+"S"))
-        apply_declaration(module.template_bracket % declaration)
-
-        self.assertEqual(queryInterface(PREFIX+"S"), module.S)
-
-
-        checker = selectChecker(module.test_instance)
-        self.assertEqual(checker.setattr_permission_id('m1'), None)
-        self.assertEqual(checker.setattr_permission_id('m2'), None)
-        self.assertEqual(checker.setattr_permission_id('m3'), None)
-        self.assertEqual(checker.setattr_permission_id('foo'), P1)
-        self.assertEqual(checker.setattr_permission_id('bar'), P1)
-        self.assertEqual(checker.setattr_permission_id('baro'), None)
-
-    def test_multiple_set_schema(self):
-
-        self.assertEqual(queryInterface(PREFIX+"S"), None)
-        self.assertEqual(queryInterface(PREFIX+"S2"), None)
-
-        declaration = ('''<class class="%s">
-                            <require
-                                permission="%s"
-                                set_schema="%s %s"/>
-                          </class>'''
-                       % (PREFIX+"test_class", P1, PREFIX+"S", PREFIX+"S2"))
-        apply_declaration(module.template_bracket % declaration)
-
-        self.assertEqual(queryInterface(PREFIX+"S"), module.S)
-        self.assertEqual(queryInterface(PREFIX+"S2"), module.S2)
-
-
-        checker = selectChecker(module.test_instance)
-        self.assertEqual(checker.setattr_permission_id('m1'), None)
-        self.assertEqual(checker.setattr_permission_id('m2'), None)
-        self.assertEqual(checker.setattr_permission_id('m3'), None)
-        self.assertEqual(checker.setattr_permission_id('foo'), P1)
-        self.assertEqual(checker.setattr_permission_id('bar'), P1)
-        self.assertEqual(checker.setattr_permission_id('foo2'), P1)
-        self.assertEqual(checker.setattr_permission_id('bar2'), P1)
-        self.assertEqual(checker.setattr_permission_id('baro'), None)
-
-    def testSimpleInterface(self):
-
-        self.assertEqual(queryInterface(PREFIX+"I"), None)
-
-        declaration = ('''<class class="%s">
-                            <require
-                                permission="%s"
-                                interface="%s"/>
-                          </class>'''
-                       % (PREFIX+"test_class", P1, PREFIX+"I"))
-        # m1 and m2 are in the interface, so should be set, and m3 should not:
-        self.assertDeclaration(declaration, m1P=P1, m2P=P1)
-
-        # Make sure we know about the interfaces
-        self.assertEqual(queryInterface(PREFIX+"I"), module.I)
-
-
-    def testMultipleInterface(self):
-
-        self.assertEqual(queryInterface(PREFIX+"I3"), None)
-        self.assertEqual(queryInterface(PREFIX+"I4"), None)
-
-        declaration = ('''<class class="%s">
-                            <require
-                                permission="%s"
-                                interface="  %s
-                                             %s  "/>
-                          </class>'''
-                       % (PREFIX+"test_class", P1, PREFIX+"I3", PREFIX+"I4"))
-        self.assertDeclaration(declaration, m3P=P1, m2P=P1)
-
-        # Make sure we know about the interfaces
-        self.assertEqual(queryInterface(PREFIX+"I3"), module.I3)
-        self.assertEqual(queryInterface(PREFIX+"I4"), module.I4)
-
-    # "testComposite*" exercises tags that DO have children.
-    # "testComposite*TopPerm" exercises tags with permission in containing tag.
-    # "testComposite*ElementPerm" exercises tags w/permission in children.
-
-    def testCompositeNoPerm(self):
-        # Establish rejection of declarations lacking a permission spec.
-        declaration = ('''<class class="%s">
-                            <require
-                                attributes="m1"/>
-                          </class>'''
-                       % (PREFIX+"test_class"))
-        self.assertRaises(ZopeXMLConfigurationError,
-                          self.assertDeclaration,
-                          declaration)
-
-
-
-    def testCompositeMethodsPluralElementPerm(self):
-        declaration = ('''<class class="%s">
-                            <require
-                                permission="%s"
-                                attributes="m1 m3"/>
-                          </class>'''
-                       % (PREFIX+"test_class", P1))
-        self.assertDeclaration(declaration,
-                               m1P=P1, m3P=P1)
-
-    def testCompositeInterfaceTopPerm(self):
-        declaration = ('''<class class="%s">
-                            <require
-                                permission="%s"
-                                interface="%s"/>
-                          </class>'''
-                       % (PREFIX+"test_class", P1, PREFIX+"I"))
-        self.assertDeclaration(declaration,
-                               m1P=P1, m2P=P1)
-
-
-    def testSubInterfaces(self):
-        declaration = ('''<class class="%s">
-                            <require
-                                permission="%s"
-                                interface="%s"/>
-                          </class>'''
-                       % (PREFIX+"test_class", P1, PREFIX+"I2"))
-        # m1 and m2 are in the interface, so should be set, and m3 should not:
-        self.assertDeclaration(declaration, m1P=P1, m2P=P1)
-
-
-    def testMimicOnly(self):
-        declaration = ('''<class class="%s">
-                            <require
-                                permission="%s"
-                                attributes="m1 m2"/>
-                          </class>
-                          <class class="%s">
-                            <require like_class="%s" />
-                          </class>
-                          ''' % (PREFIX+"test_base", P1,
-                PREFIX+"test_class", PREFIX+"test_base"))
-        # m1 and m2 are in the interface, so should be set, and m3 should not:
-        self.assertDeclaration(declaration,
-                               m1P=P1, m2P=P1)
-
-
-    def testMimicAsDefault(self):
-        declaration = ('''<class class="%s">
-                            <require
-                                permission="%s"
-                                attributes="m1 m2"/>
-                          </class>
-                          <class class="%s">
-                            <require like_class="%s" />
-                            <require
-                                permission="%s"
-                                attributes="m2 m3"/>
-                          </class>
-                          ''' % (PREFIX+"test_base", P1,
-                PREFIX+"test_class", PREFIX+"test_base", P2))
-
-        # m1 and m2 are in the interface, so should be set, and m3 should not:
-        self.assertDeclaration(declaration,
-                               m1P=P1, m2P=P2, m3P=P2)
-
-
-def apply_declaration(declaration):
-    '''Apply the xmlconfig machinery.'''
-    return xmlconfig(StringIO(declaration))
-
-
-def test_suite():
-    return unittest.TestSuite((
-        unittest.makeSuite(Test),
-        unittest.makeSuite(TestFactoryDirective),
-        unittest.makeSuite(TestRequireDirective),
-        DocTestSuite(),
-        ))
-
-if __name__ == "__main__":
-    unittest.TextTestRunner().run(test_suite())

Modified: zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/test_vocabulary.py
===================================================================
--- zope.componentvocabulary/trunk/src/zope/app/component/tests/test_vocabulary.py	2009-05-19 19:14:48 UTC (rev 100131)
+++ zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/test_vocabulary.py	2009-05-19 20:15:33 UTC (rev 100139)
@@ -20,4 +20,4 @@
 
 
 def test_suite():
-    return doctest.DocTestSuite('zope.app.component.vocabulary')
+    return doctest.DocTestSuite('zope.componentvocabulary.vocabulary')

Deleted: zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/views.py
===================================================================
--- zope.componentvocabulary/trunk/src/zope/app/component/tests/views.py	2009-05-19 19:14:48 UTC (rev 100131)
+++ zope.componentvocabulary/trunk/src/zope/componentvocabulary/tests/views.py	2009-05-19 20:15:33 UTC (rev 100139)
@@ -1,65 +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.
-#
-##############################################################################
-"""Views test.
-
-$Id: views.py 26551 2004-07-15 07:06:37Z srichter $
-"""
-from zope.interface import Interface, implements, directlyProvides
-
-class Request(object):
-
-    def __init__(self, type):
-        directlyProvides(self, type)
-
-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

Modified: zope.componentvocabulary/trunk/src/zope/componentvocabulary/vocabulary.py
===================================================================
--- zope.componentvocabulary/trunk/src/zope/app/component/vocabulary.py	2009-05-19 19:14:48 UTC (rev 100131)
+++ zope.componentvocabulary/trunk/src/zope/componentvocabulary/vocabulary.py	2009-05-19 20:15:33 UTC (rev 100139)
@@ -20,15 +20,17 @@
 __docformat__ = "reStructuredText"
 
 import zope.component
-from zope.interface import implements, classProvides, Interface
+from zope.component.interface import interfaceToName
+from zope.component.interfaces import IUtilityRegistration
+from zope.interface import implements, classProvides, Interface, providedBy
 from zope.interface.interfaces import IInterface
+from zope.security.proxy import removeSecurityProxy
 from zope.schema.interfaces import IVocabularyTokenized
 from zope.schema.interfaces import ITokenizedTerm, ITitledTokenizedTerm
 from zope.schema.interfaces import IVocabularyFactory
+from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
 
-from zope.app.component.i18n import ZopeMessageFactory as _
-from zope.app.interface.vocabulary import ObjectInterfacesVocabulary
-from zope.component.interfaces import IUtilityRegistration
+from zope.componentvocabulary.i18n import ZopeMessageFactory as _
 
 class UtilityTerm(object):
     """A term representing a utility.
@@ -82,13 +84,13 @@
 
     Now we register some utilities for IObject
 
-    >>> from zope.app.testing import ztapi
+    >>> from zope import component
     >>> object1 = Object('object1')
-    >>> ztapi.provideUtility(IObject, object1, 'object1')
+    >>> component.provideUtility(object1, IObject, 'object1')
     >>> object2 = Object('object2')
-    >>> ztapi.provideUtility(IObject, object2, 'object2')
+    >>> component.provideUtility(object2, IObject, 'object2')
     >>> object3 = Object('object3')
-    >>> ztapi.provideUtility(IObject, object3, 'object3')
+    >>> component.provideUtility(object3, IObject, 'object3')
     >>> object4 = Object('object4')
 
     We are now ready to create a vocabulary that we can use; in our case
@@ -158,7 +160,7 @@
         factory='zope.app.utility.vocabulary.UtilityVocabulary'
         interface='zope.app.utility.vocabulary.IObject' />
 
-    >>> ztapi.provideUtility(IInterface, IObject,
+    >>> component.provideUtility(IObject, IInterface, 
     ...                      'zope.app.utility.vocabulary.IObject')
     >>> vocab = UtilityVocabulary(
     ...     None, interface='zope.app.utility.vocabulary.IObject')
@@ -233,7 +235,44 @@
     classProvides(IVocabularyFactory)
     interface = IInterface
 
+class ObjectInterfacesVocabulary(SimpleVocabulary):
+    """A vocabulary that provides a list of all interfaces that its context
+    provides.
 
+    Here a quick demonstration:
+
+    >>> from zope.interface import Interface, implements
+    >>> class I1(Interface):
+    ...     pass
+    >>> class I2(Interface):
+    ...     pass
+    >>> class I3(I2):
+    ...     pass
+
+    >>> class Object(object):
+    ...     implements(I3, I1)
+
+    >>> vocab = ObjectInterfacesVocabulary(Object())
+    >>> import pprint
+    >>> names = [term.token for term in vocab]
+    >>> names.sort()
+    >>> pprint.pprint(names)
+    ['zope.componentvocabulary.vocabulary.I1',
+     'zope.componentvocabulary.vocabulary.I2',
+     'zope.componentvocabulary.vocabulary.I3',
+     'zope.interface.Interface']
+    """
+    classProvides(IVocabularyFactory)
+
+    def __init__(self, context):
+        # Remove the security proxy so the values from the vocabulary
+        # are the actual interfaces and not proxies.
+        component = removeSecurityProxy(context)
+        interfaces = providedBy(component).flattened()
+        terms = [SimpleTerm(interface, interfaceToName(context, interface))
+                 for interface in interfaces]
+        super(ObjectInterfacesVocabulary, self).__init__(terms)
+
 class UtilityComponentInterfacesVocabulary(ObjectInterfacesVocabulary):
     classProvides(IVocabularyFactory)
 
@@ -313,12 +352,13 @@
     >>> IVocabularyTokenized.providedBy(vocab)
     True
 
-    >>> from zope.app.testing import placelesssetup
-    >>> from zope.app.testing import ztapi
-    >>> placelesssetup.setUp()
+    >>> from zope.component.testing import PlacelessSetup
+    >>> from zope import component
+    >>> ps = PlacelessSetup()
+    >>> ps.setUp()
 
-    >>> ztapi.provideUtility(IMyUtility, MyUtility(), 'one')
-    >>> ztapi.provideUtility(IMyUtility, MyUtility(), 'two')
+    >>> component.provideUtility(MyUtility(), IMyUtility, 'one')
+    >>> component.provideUtility(MyUtility(), IMyUtility, 'two')
 
     >>> unames = UtilityNames(IMyUtility)
     >>> len(list(unames))
@@ -332,11 +372,11 @@
     True
     >>> u'three' in vocab
     False
-    >>> ztapi.provideUtility(IMyUtility, MyUtility(), 'three')
+    >>> component.provideUtility(MyUtility(), IMyUtility, 'three')
     >>> u'three' in vocab
     True
 
-    >>> ztapi.provideUtility(IMyUtility, MyUtility())
+    >>> component.provideUtility(MyUtility(), IMyUtility)
     >>> u'' in vocab
     True
     >>> term1 = vocab.getTerm(u'')
@@ -350,7 +390,7 @@
     >>> term3.value
     u'one'
 
-    >>> placelesssetup.tearDown()
+    >>> ps.tearDown()
     """
 
     implements(IVocabularyTokenized)



More information about the Checkins mailing list