2015-07-21 1 views
1

Je suis en train de comprendre les annotations de ce document:L'exemple zope.annotation dans la documentation échoue. Besoin d'aide pour corriger

http://docs.zope.org/zope.annotation/index.html

Cependant l'exemple échoue lors de son exécution.

je reçois:

Traceback (most recent call last): 
    File "./zopepy", line 366, in <module> 
    exec(compile(__file__f.read(), __file__, "exec")) 
    File "test1.py", line 29, in <module> 
    bar = IBar(foo) 
    File "eggs/zope.component-3.9.5-py2.7.egg/zope/component/_api.py", line 156, in adapter_hook 
    return sitemanager.queryAdapter(object, interface, name, default) 
    File "eggs/zope.component-3.9.5- py2.7.egg/zope/component/registry.py", line 228, in queryAdapter 
    return self.adapters.queryAdapter(object, interface, name, default) 
    File "eggs/zope.annotation-3.5.0-py2.7.egg/zope/annotation/factory.py", line 42, in getAnnotation 
    annotations = zope.annotation.interfaces.IAnnotations(context) 
TypeError: ('Could not adapt', <__main__.Foo object at 0xb6d6956c>, <InterfaceClass zope.annotation.interfaces.IAnnotations>) 

Répondre

1

Exemple manquant les énoncés suivants:

from zope.annotation.attribute import AttributeAnnotations 
provideAdapter(AttributeAnnotations)