Hi, I'm stuck with testing (= developing) my components. I have an interface with a zope.schema.Choice field where the vocabulary is zope3's vocabulary named 'Interfaces' from the zope.app.component package.
The problem with testing occures when I try to assign a value to the field, inspite of providing the interface in the test and having registered the InterfaceVocabulary from zope.app.component.vocabulary for the test. The traceback says that an adapter is missing - but which one? A part of the registry seems to be missing. (I don't want to bring up the whole system because of performance--I develop components while writing tests in emacs doctest-mode and driving the test again and again ...) Here is the interface: import zope.interface import zope.schema from zope.app.container.interfaces import IContained, IContainer from zope.app.container.constraints import containers, contains from zope.i18nmessageid import MessageFactory _ = ReferatoryMessageFactory = MessageFactory('quotationtool') ... class ICategorizableItemDescription(IContained): """A description of a ZOPE3 interface which users can understand. It is used to create a term for the vocabulary of categorizable item classes. The label will be used as the title of the term instead of the python module name of the interface.""" containers(ICategorizableItemDescriptions) interface = zope.schema.Choice( title = _('icategorizableitemdescription-interface-title', u"Interface"), description = _('icategorizableitemdescription-interface-desc', u"Choose an ZOPE-Interface from the list."), required = True, vocabulary = 'Interfaces', ) label = zope.schema.TextLine( title = _('icategorizableitemdescription-label-title', u"Label"), description = _('icategorrizableitemdescription-label-description', u"Descriptive term for the interface which users can understand."), required = True, ) Here is what is brought up for the test: ... from quotationtool.categorization.weighteditemscontainer import updateWeightedItemsContainerOrder from quotationtool.categorization.categorizableitemdescription import categorizableItemDescriptionVocabulary from quotationtool.categorization.mode import modeVocabulary def setUp(test): zope.component.testing.setUp(test) zope.component.eventtesting.setUp(test) zope.component.provideHandler(updateWeightedItemsContainerOrder) vocabulary.setVocabularyRegistry(vocabulary.VocabularyRegistry()) vr = vocabulary.getVocabularyRegistry() vr.register('quotationtool.categorization.categorizableitemdescription', categorizableItemDescriptionVocabulary) vr.register('quotationtool.categorization.mode', modeVocabulary) vr.register('Interfaces', InterfacesVocabulary) ... Here are the first lines of the test and the traceback: >>> from quotationtool.categorization import interfaces >>> import zope.interface >>> import zope.component >>> from quotationtool.categorization.categorizableitemdescription\ ... import CategorizableItemDescription, CategorizableItemDescriptions >>> publication_desc = CategorizableItemDescription() >>> class IPublication(zope.interface.Interface): ... pass >>> zope.component.interface.provideInterface('.IPublication', IPublication) >>> iface = zope.component.interface.getInterface(None, '.IPublication') >>> iface == IPublication True >>> publication_desc.interface = IPublication Traceback (most recent call last): File "/home/clueck/.buildout-eggs/zope.testing-3.7.1-py2.4.egg/zope/testing/doctest.py", line 1356, in __run compileflags, 1) in test.globs File "<doctest README.txt[10]>", line 1, in ? publication_desc.interface = IPublication File "/home/clueck/.buildout-eggs/zope.schema-3.5.0a2-py2.4.egg/zope/schema/fieldproperty.py", line 51, in __set__ field = self.__field.bind(inst) File "/home/clueck/.buildout-eggs/zope.schema-3.5.0a2-py2.4.egg/zope/schema/_field.py", line 2 86, in bind clone.vocabulary = vr.get(object, self.vocabularyName) File "/home/clueck/.buildout-eggs/zope.schema-3.5.0a2-py2.4.egg/zope/schema/vocabulary.py", li ne 166, in get return vtype(object) File "/home/clueck/.buildout-eggs/zope.app.component-3.5.0-py2.4.egg/zope/app/component/vocabu lary.py", line 197, in __init__ utils = zope.component.getUtilitiesFor(self.interface, context) File "/home/clueck/.buildout-eggs/zope.component-3.5.1-py2.4.egg/zope/component/_api.py", line 212, in getUtilitiesFor return getSiteManager(context).getUtilitiesFor(interface) File "/home/clueck/.buildout-eggs/zope.component-3.5.1-py2.4.egg/zope/component/_api.py", line 51, in getSiteManager raise ComponentLookupError(*error.args) ComponentLookupError: ('Could not adapt', <quotationtool.categorization.categorizableitemdescrip tion.CategorizableItemDescription object at 0xb71b556c>, <InterfaceClass zope.component.interfaces.I ComponentLookup>) An adapter seems to be missing. That adapter--I guess--adapts to * Which component should I register? Regards, Christian _______________________________________________ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users