[Zope3-checkins]
SVN: Zope3/branches/philikon-reduce-zcml/src/zope/app/schema/
Deprecate the <vocabulary /> directive.
Philipp von Weitershausen
philikon at philikon.de
Sat Feb 25 15:52:13 EST 2006
Log message for revision 65478:
Deprecate the <vocabulary /> directive.
Put IVocabularyFactory into a more public place (zope.app.schema.interfaces).
Changed:
U Zope3/branches/philikon-reduce-zcml/src/zope/app/schema/interfaces.py
U Zope3/branches/philikon-reduce-zcml/src/zope/app/schema/metaconfigure.py
U Zope3/branches/philikon-reduce-zcml/src/zope/app/schema/metadirectives.py
U Zope3/branches/philikon-reduce-zcml/src/zope/app/schema/vocabulary.py
-=-
Modified: Zope3/branches/philikon-reduce-zcml/src/zope/app/schema/interfaces.py
===================================================================
--- Zope3/branches/philikon-reduce-zcml/src/zope/app/schema/interfaces.py 2006-02-25 20:50:44 UTC (rev 65477)
+++ Zope3/branches/philikon-reduce-zcml/src/zope/app/schema/interfaces.py 2006-02-25 20:52:12 UTC (rev 65478)
@@ -19,6 +19,13 @@
from zope.interface.interfaces import IInterface
from zope.app.container.interfaces import IAdding
+class IVocabularyFactory(Interface):
+ """Can create vocabularies."""
+
+ def __call__(self, context):
+ """The context provides a location that the vocabulary can make use
+ of."""
+
class ISchemaUtility(Interface):
pass
Modified: Zope3/branches/philikon-reduce-zcml/src/zope/app/schema/metaconfigure.py
===================================================================
--- Zope3/branches/philikon-reduce-zcml/src/zope/app/schema/metaconfigure.py 2006-02-25 20:50:44 UTC (rev 65477)
+++ Zope3/branches/philikon-reduce-zcml/src/zope/app/schema/metaconfigure.py 2006-02-25 20:52:12 UTC (rev 65478)
@@ -15,8 +15,9 @@
$Id$
"""
+import warnings
from zope.interface import directlyProvides
-from vocabulary import IVocabularyFactory
+from zope.app.schema.interfaces import IVocabularyFactory
from zope.app.component.metaconfigure import utility
class FactoryKeywordPasser(object):
@@ -30,9 +31,23 @@
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.app.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)
-
Modified: Zope3/branches/philikon-reduce-zcml/src/zope/app/schema/metadirectives.py
===================================================================
--- Zope3/branches/philikon-reduce-zcml/src/zope/app/schema/metadirectives.py 2006-02-25 20:50:44 UTC (rev 65477)
+++ Zope3/branches/philikon-reduce-zcml/src/zope/app/schema/metadirectives.py 2006-02-25 20:52:12 UTC (rev 65478)
@@ -19,6 +19,7 @@
from zope.interface import Interface
from zope.schema import TextLine
+# BBB 2006/02/24, to be removed after 12 months
class IVocabularyDirective(Interface):
'''Define a named vocabulary.
Modified: Zope3/branches/philikon-reduce-zcml/src/zope/app/schema/vocabulary.py
===================================================================
--- Zope3/branches/philikon-reduce-zcml/src/zope/app/schema/vocabulary.py 2006-02-25 20:50:44 UTC (rev 65477)
+++ Zope3/branches/philikon-reduce-zcml/src/zope/app/schema/vocabulary.py 2006-02-25 20:52:12 UTC (rev 65478)
@@ -20,16 +20,8 @@
from zope.schema.interfaces import IVocabularyRegistry
from zope.schema import vocabulary
from zope.testing import cleanup
+from zope.app.schema.interfaces import IVocabularyFactory
-
-class IVocabularyFactory(Interface):
- """Can create vocabularies."""
-
- def __call__(self, context):
- """The context provides a location that the vocabulary can make use
- of."""
-
-
class ZopeVocabularyRegistry(object):
"""IVocabularyRegistry that supports global and local utilities."""
More information about the Zope3-Checkins
mailing list