2017-04-11 1 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')" 
관련 문제