【问题标题】:zope.annotation example in documentation fails. Help needed to correct it文档中的 zope.annotation 示例失败。需要帮助来纠正它
【发布时间】:2015-07-21 05:18:04
【问题描述】:

我正在尝试理解此文档中的注释:

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

【问题讨论】:

    标签: plone zope.interface zope.component


    【解决方案1】:

    缺少以下语句的示例:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-01
      • 2014-06-20
      • 1970-01-01
      • 2022-09-24
      • 2021-12-18
      • 2017-04-26
      相关资源
      最近更新 更多