Plone:在页面模板中获取词汇
Plone: get vocabulary in a page template
我正在尝试这个:tal:define="terms python:context.portal_vocabularies.getVocabularyByName('a_vocabulary').items()"
结果是
Unauthorized: You are not allowed to access 'portal_vocabularies' in this context
知道如何在页面模板中获取我的词汇吗?
(它适用于经过身份验证的用户。错误仅适用于匿名用户。)
不确定这是最简单的...添加了浏览器视图:
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
是public
<browser:page
name="get_a_vocabulary"
for="*"
permission="zope2.View"
class=".views.AVocabulary"
/>
它正在运行:
tal:define="options python:context.restrictedTraverse('get_a_vocabulary')"
我正在尝试这个:tal:define="terms python:context.portal_vocabularies.getVocabularyByName('a_vocabulary').items()"
结果是
Unauthorized: You are not allowed to access 'portal_vocabularies' in this context
知道如何在页面模板中获取我的词汇吗?
(它适用于经过身份验证的用户。错误仅适用于匿名用户。)
不确定这是最简单的...添加了浏览器视图:
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
是public
<browser:page
name="get_a_vocabulary"
for="*"
permission="zope2.View"
class=".views.AVocabulary"
/>
它正在运行:
tal:define="options python:context.restrictedTraverse('get_a_vocabulary')"