2017-04-11 6 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')" 
関連する問題