2011-12-11 4 views
2

다음 예제에서는 ICarentInterface를 구현하는 개체에 IChildInterface를 구현하는 개체 목록 인 mycollection 특성을 제공해야합니다.zope.interface.Interface는 다른 인터페이스를 구현하는 객체의 목록을 구현해야합니까?

from zope.schema import Text, List 
from zope.interface import Interface 

class IChildInterface(Interface): 
    someField = Text() 

class IParentInterface(Interface): 
    mycollection = List(value_type=IChildInterface) 

이 할 수있는 간단한 방법이 있나요, 아니면 불변을 사용해야합니다?

답변

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)) 
관련 문제