I'm trying this: tal:define="terms python:context.portal_vocabularies.getVocabularyByName('a_vocabulary').items()"
and the result is
Unauthorized: You are not allowed to access 'portal_vocabularies' in this context
Any idea how to get my vocabulary in a page template?
(It's working for authenticated users. The error is only for anonymous.)
Not sure it's the easiest... Added a browser view:
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
it's public
<browser:page
name="get_a_vocabulary"
for="*"
permission="zope2.View"
class=".views.AVocabulary"
/>
and it's working:
tal:define="options python:context.restrictedTraverse('get_a_vocabulary')"