2017-04-11 115 views
1

得到的詞彙我想這一點:tal:define="terms python:context.portal_vocabularies.getVocabularyByName('a_vocabulary').items()"Plone的:在一個頁面模板

,其結果是 Unauthorized: You are not allowed to access 'portal_vocabularies' in this context

不知道如何讓我的詞彙量在一個頁面模板?

(。它的工作通過驗證的用戶僅錯誤是匿名)

+0

通過在我們的論壇community.plone.org上發帖,您將有更好的運氣獲得答案,儘管我在論壇上發佈了關於您的問題的鏈接 –

回答

2

不知道這是最簡單的...添加了一個瀏覽器視圖:

class AVocabulary(BrowserView): 
    def __call__(self): 
     terms = self.context.portal_vocabularies.getVocabularyByName(
      'a_vocabulary').items() 
     res = [(t[0], t[1].title) for t in terms] 
     return res 

是公開

<browser:page 
    name="get_a_vocabulary" 
    for="*" 
    permission="zope2.View" 
    class=".views.AVocabulary" 
    /> 

,它的工作:

tal:define="options python:context.restrictedTraverse('get_a_vocabulary')"