[Checkins] SVN: zope.app.schema/trunk/ Remove deprecated vocabulary directive. Add test for component-based vocabulary registry.

Dan Korostelev nadako at gmail.com
Tue Dec 16 03:25:07 EST 2008


Log message for revision 94098:
  Remove deprecated vocabulary directive. Add test for component-based vocabulary registry.

Changed:
  _U  zope.app.schema/trunk/
  U   zope.app.schema/trunk/CHANGES.txt
  U   zope.app.schema/trunk/README.txt
  U   zope.app.schema/trunk/buildout.cfg
  U   zope.app.schema/trunk/setup.py
  A   zope.app.schema/trunk/src/zope/app/schema/README.txt
  D   zope.app.schema/trunk/src/zope/app/schema/meta.zcml
  D   zope.app.schema/trunk/src/zope/app/schema/metaconfigure.py
  D   zope.app.schema/trunk/src/zope/app/schema/metadirectives.py
  D   zope.app.schema/trunk/src/zope/app/schema/tests/
  A   zope.app.schema/trunk/src/zope/app/schema/tests.py

-=-

Property changes on: zope.app.schema/trunk
___________________________________________________________________
Modified: svn:ignore
   - bin
build
dist
lib
develop-eggs
eggs
parts
.installed.cfg

   + bin
build
dist
lib
develop-eggs
eggs
parts
.installed.cfg
coverage


Modified: zope.app.schema/trunk/CHANGES.txt
===================================================================
--- zope.app.schema/trunk/CHANGES.txt	2008-12-16 07:53:15 UTC (rev 94097)
+++ zope.app.schema/trunk/CHANGES.txt	2008-12-16 08:25:06 UTC (rev 94098)
@@ -2,6 +2,12 @@
 CHANGES
 =======
 
+3.5.0 (unreleased)
+------------------
+
+- Remove deprecated ``vocabulary`` directive.
+- Add test for component-based vocabulary registry.
+
 3.4.0 (2007-10-27)
 ------------------
 

Modified: zope.app.schema/trunk/README.txt
===================================================================
--- zope.app.schema/trunk/README.txt	2008-12-16 07:53:15 UTC (rev 94097)
+++ zope.app.schema/trunk/README.txt	2008-12-16 08:25:06 UTC (rev 94098)
@@ -1,2 +1 @@
-This package provides a component architecture based vocabulary registry. It
-also contains the deprecated `vocabulary` ZCML directive.
+This package provides a component architecture based vocabulary registry.

Modified: zope.app.schema/trunk/buildout.cfg
===================================================================
--- zope.app.schema/trunk/buildout.cfg	2008-12-16 07:53:15 UTC (rev 94097)
+++ zope.app.schema/trunk/buildout.cfg	2008-12-16 08:25:06 UTC (rev 94098)
@@ -1,8 +1,18 @@
 [buildout]
 develop = .
-parts = test
+parts = test coverage-test coverage-report
 
 [test]
 recipe = zc.recipe.testrunner
 eggs = zope.app.schema [test]
 
+[coverage-test]
+recipe = zc.recipe.testrunner
+eggs = zope.app.schema [test]
+defaults = ['--coverage', '../../coverage']
+
+[coverage-report]
+recipe = zc.recipe.egg
+eggs = z3c.coverage
+scripts = coverage=coverage-report
+arguments = ('coverage', 'coverage/report')

Modified: zope.app.schema/trunk/setup.py
===================================================================
--- zope.app.schema/trunk/setup.py	2008-12-16 07:53:15 UTC (rev 94097)
+++ zope.app.schema/trunk/setup.py	2008-12-16 08:25:06 UTC (rev 94098)
@@ -22,7 +22,7 @@
     return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
 
 setup(name='zope.app.schema',
-      version = '3.5.0',
+      version = '3.5.0dev',
       author='Zope Corporation and Contributors',
       author_email='zope3-dev at zope.org',
       description='Component Architecture based Vocabulary Registry',
@@ -50,7 +50,6 @@
       extras_require = dict(test=['zope.app.testing']),
       install_requires=['setuptools',
                         'zope.component',
-                        'zope.configuration',
                         'zope.interface',
                         'zope.schema',
                         ],

Added: zope.app.schema/trunk/src/zope/app/schema/README.txt
===================================================================
--- zope.app.schema/trunk/src/zope/app/schema/README.txt	                        (rev 0)
+++ zope.app.schema/trunk/src/zope/app/schema/README.txt	2008-12-16 08:25:06 UTC (rev 94098)
@@ -0,0 +1,31 @@
+Component-based Vocabulary Registry
+===================================
+
+This package provides a vocabulary registry for zope.schema,
+based on the component architecture.
+
+It replaces the zope.schema's simple vocabulary registry
+when ``zope.app.schema`` package is imported, so it's done
+automatically. All we need is provide vocabulary factory
+utilities:
+
+  >>> from zope.component import provideUtility
+  >>> from zope.schema.interfaces import IVocabularyFactory
+  >>> from zope.schema.vocabulary import SimpleTerm
+  >>> from zope.schema.vocabulary import SimpleVocabulary
+  
+  >>> def SomeVocabulary(context=None):
+  ...     terms = [SimpleTerm(1), SimpleTerm(2)]
+  ...     return SimpleVocabulary(terms)
+
+  >>> provideUtility(SomeVocabulary, IVocabularyFactory,
+  ...                name='SomeVocabulary')
+
+Now we can get the vocabulary using standard zope.schema
+way:
+
+  >>> from zope.schema.vocabulary import getVocabularyRegistry
+  >>> vr = getVocabularyRegistry()
+  >>> voc = vr.get(None, 'SomeVocabulary')
+  >>> [term.value for term in voc]
+  [1, 2]
\ No newline at end of file

Deleted: zope.app.schema/trunk/src/zope/app/schema/meta.zcml
===================================================================
--- zope.app.schema/trunk/src/zope/app/schema/meta.zcml	2008-12-16 07:53:15 UTC (rev 94097)
+++ zope.app.schema/trunk/src/zope/app/schema/meta.zcml	2008-12-16 08:25:06 UTC (rev 94098)
@@ -1,12 +0,0 @@
-<configure
-    xmlns="http://namespaces.zope.org/zope"
-    xmlns:meta="http://namespaces.zope.org/meta">
-
-  <!-- BBB 2006/02/24, to be removed after 12 months -->
-  <meta:directive 
-      namespace="http://namespaces.zope.org/zope"
-      name="vocabulary" 
-      schema=".metadirectives.IVocabularyDirective"
-      handler=".metaconfigure.vocabulary" />
-
-</configure>

Deleted: zope.app.schema/trunk/src/zope/app/schema/metaconfigure.py
===================================================================
--- zope.app.schema/trunk/src/zope/app/schema/metaconfigure.py	2008-12-16 07:53:15 UTC (rev 94097)
+++ zope.app.schema/trunk/src/zope/app/schema/metaconfigure.py	2008-12-16 08:25:06 UTC (rev 94098)
@@ -1,53 +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.
-#
-##############################################################################
-"""ZCML special vocabulary directive handlers
-
-$Id$
-"""
-import warnings
-from zope.interface import directlyProvides
-from zope.schema.interfaces import IVocabularyFactory
-from zope.component.zcml import utility
-
-class FactoryKeywordPasser(object):
-    """Helper that passes additional keywords to the actual factory."""
-
-    def __init__(self, factory, kwargs):
-        self.factory = factory
-        self.kwargs = kwargs
-
-    def __call__(self, object):
-        return self.factory(object, **self.kwargs)
-
-
-# BBB 2006/02/24, to be removed after 12 months
-def vocabulary(_context, name, factory, **kw):
-    try:
-        dottedname = factory.__module__ + "." + factory.__name__
-    except AttributeError:
-        dottedname = '...'
-    warnings.warn_explicit(
-        "The 'vocabulary' directive has been deprecated and will be "
-        "removed in Zope 3.5.  Use the 'utility' directive instead to "
-        "register the class as a named utility:\n"
-        '  <utility\n'
-        '      provides="zope.schema.interfaces.IVocabularyFactory"\n'
-        '      component="%s"\n'
-        '      name="%s"\n'
-        '      />' % (dottedname, name),
-        DeprecationWarning, _context.info.file, _context.info.line)
-    if kw:
-        factory = FactoryKeywordPasser(factory, kw)
-    directlyProvides(factory, IVocabularyFactory)
-    utility(_context, IVocabularyFactory, factory, name=name)

Deleted: zope.app.schema/trunk/src/zope/app/schema/metadirectives.py
===================================================================
--- zope.app.schema/trunk/src/zope/app/schema/metadirectives.py	2008-12-16 07:53:15 UTC (rev 94097)
+++ zope.app.schema/trunk/src/zope/app/schema/metadirectives.py	2008-12-16 08:25:06 UTC (rev 94098)
@@ -1,75 +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.
-#
-##############################################################################
-"""Renderer configuration code
-
-$Id$
-"""
-from zope.configuration.fields import GlobalObject
-from zope.interface import Interface
-from zope.schema import TextLine
-
-# BBB 2006/02/24, to be removed after 12 months
-class IVocabularyDirective(Interface):
-    '''
-    *BBB: DEPRECATED*
-
-    The 'vocabulary' directive has been deprecated and will be
-    removed in Zope 3.5.  Use the 'utility' directive instead to
-    register the class as a named utility:
-
-    Example::
-
-      <utility
-          provides="zope.schema.interfaces.IVocabularyFactory"
-          component="zope.app.gary.paths.Favorites"
-          name="garys-favorite-path-references"
-          />
-
-    **Previous documentation**
-
-    Define a named vocabulary.
-
-    This associates a vocabulary name in the global vocabulary registry with a
-    factory.  Each name may only be defined once.
-
-    Additional keyword arguments may be passed to the factory by adding
-    additional attributes beyond those listed here.  This can be useful when
-    using vocabularies which implement various kinds of filtering.
-
-    Example::
-
-       <vocabulary
-           name="garys-favorite-path-references"
-           factory="zope.app.gary.paths.Favorites" />
-    '''
-
-    name = TextLine(
-        title=u"Name",
-        description=u'Provides a title for the source type. The name of the ' \
-                    u'vocabulary; this can be used as the value for the ' \
-                    u'"vocabulary" argument to the Choice field ' \
-                    u'constructor to cause this vocabulary to be used.',
-        required=True)
-
-    factory = GlobalObject(
-        title=u"Factory",
-        description=u"Factory that returns an instance of the named " \
-                    u"vocabulary when called with the context object as " \
-                    u"the only argument.  This should be a dotted-name " \
-                    u"that refers to a Python object.",
-        required=True)
-
-
-# Arbitrary keys and values are allowed to be passed to the vocabulary source.
-IVocabularyDirective.setTaggedValue('keyword_arguments', True)

Added: zope.app.schema/trunk/src/zope/app/schema/tests.py
===================================================================
--- zope.app.schema/trunk/src/zope/app/schema/tests.py	                        (rev 0)
+++ zope.app.schema/trunk/src/zope/app/schema/tests.py	2008-12-16 08:25:06 UTC (rev 94098)
@@ -0,0 +1,19 @@
+import unittest
+from zope.testing import doctest
+from zope.app.testing import setup
+from zope.app.schema.vocabulary import _clear
+
+def setUp(test):
+    setup.placefulSetUp()
+    _clear()
+
+def tearDown(test):
+    setup.placefulTearDown()
+
+def test_suite():
+    return unittest.TestSuite((
+        doctest.DocFileSuite('README.txt',
+                     setUp=setUp, tearDown=tearDown,
+                     optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+                     ),
+        ))



More information about the Checkins mailing list