2013-02-20 63 views
2

我寫了一個靈巧型與現場有關的另一個對象:如何在zope模板中打印相關對象的屬性?

institution = RelationChoice(
    title=_(u"Institution"), 
    source=ObjPathSourceBinder(
     object_provides=IInstitution.__identifier__ 
    ), 
) 

而且也是我寫的模板:

<span id="institution" tal:content="context/institution" /> 

但它打印:

<z3c.relationfield.relation.RelationValue object at 0xe3a032c> 

我有試圖獲得屬性來建立該項目的鏈接,但接下來不起作用:

<span id="institution" tal:content="context/institution/absolute_url" /> 

如何獲取objecto的屬性以創建鏈接?

回答

3

參考對象記錄在in the Dexterity developer manual。您正在尋找to_object屬性:

<span id="institution" tal:content="context/institution/to_object/absolute_url" /> 

這將插入鏈接對象的網址,或者你可以顯示Title代替:

<span id="institution" tal:content="context/institution/to_object/Title" />