2010-05-19 22 views
3

我想註冊一個標記界面,以便我可以將它添加到ZMI中的對象。我的產品的configure.zcml包含:如何註冊標記界面,以便在Plone的ZMI中可見?

<interface interface=".interfaces.IMarkerInterface" /> 

,並重新安裝後,該接口可用接口的列表中顯示。但如果我嘗試將它添加到ZMI中的對象,我會得到一個ComponentLookupError。少了什麼東西?

+0

您能否包含錯誤的完整回溯? – 2010-05-19 19:47:53

+0

我添加了一個僞造的,它提供了有問題的接口,它現在似乎可行,但我不知道爲什麼。 – joeforker 2010-05-19 21:48:04

回答

4

它爲我工作好。

我測試了它在Plone 4.0.3

創建一個包,貼膜:

paster create -t plone bogus.interface

有了這個interfaces.py文件:

from zope.interface import Interface 

class IBogusInterface(Interface): 
    """ Marker bogus interface 
    """ 

這configure.zcml中文件:

<configure 
    xmlns="http://namespaces.zope.org/zope" 
    xmlns:five="http://namespaces.zope.org/five" 
    xmlns:i18n="http://namespaces.zope.org/i18n" 
    i18n_domain="bogus.interface"> 

    <five:registerPackage package="." initialize=".initialize" /> 

    <!-- -*- extra stuff goes here -*- --> 
    <interface interface=".interfaces.IBogusInterface" /> 

</configure> 

你確定你沒有遺漏任何東西嗎?

3

另外請注意,顯然,標記接口必須爲空。他們不能包含屬性或方法 - 如果他們這樣做,他們將不會出現在ZMI中。

相關問題