簡體   English   中英

文檔中的zope.annotation示例失敗。 需要幫助來糾正它

[英]zope.annotation example in documentation fails. Help needed to correct it

我試圖從此文檔中了解注釋:

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

但是,該示例在運行時失敗。

我得到:

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>)

示例缺少以下語句:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM