在下面的示例中,我希望实现IParentInterface的对象需要提供mycollection属性,该属性是实现IChildInterface的对象列表。
from zope.schema import Text, List
from zope.interface import Interface
class IChildInterface(Interface):
someField = Text()
class IParentInterface(Interface):
mycollection = List(value_type=IChildInterface)
有没有直接的方法,或者我需要使用不变量?
答案 0 :(得分:4)
这应该有效:
from zope.schema import Text, List, Object
from zope.interface import Interface
class IChildInterface(Interface):
someField = Text()
class IParentInterface(Interface):
mycollection = List(value_type=Object(title=u'Child',
schema=IChildInterface))