I have run into a LocationError trying to invoke metal:use-macro="context/main_template/macros/master"
on an item in the private state.
In the portal_skins/custom
page template below (yeah DON'T GIVE ME GRIEF this is for TTW training I DON'T WANNA HEAR ABOUT BROWSER VIEWS la la la la la this means you @robzonenet) if I use on a content item that is in the private state, everything works when I am logged in.
But if I am logged out, I get the error trace below.
Is it not possible for anonymous users to get to the main_template
on private content?
A workaround is to give "Access contents info" and "View" permissions to Anonymous in that workflow state, but I'd really rather not... I'd like to keep private things private.
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
lang="en"
metal:use-macro="context/main_template/macros/master"
i18n:domain="Plone.dexterity">
<body>
<metal:main fill-slot="main">
<tal:canorcannot define="checkPermission nocall: context/portal_membership/checkPermission; canedit python:checkPermission('Modify portal content',context)" >
<tal:anon condition="not: canedit">
<h2>Thank you</h2>
We will respond to your question as soon as possible!
</tal:anon>
<tal:canedit condition="canedit">
<div tal:define="portal_name here/portal_url/Title;
subject python: 'Your inquiry at ' + portal_name;
question_encoded python: context.your_question.replace('&', '&').replace('<', '<').replace('>', '>').replace(' ', '%20');
question_encoded_quoted python: '> ' + question_encoded;
subject_encoded python: subject.replace('&', '&').replace('<', '<').replace('>', '>').replace(' ', '%20');">
<h3>From: <span tal:replace="here/your_full_name">[name]</span></h3>
<p>Question: <span tal:replace="here/your_question">[question]</span></p>
<p><a tal:attributes="href python: 'mailto:' + context.your_email_address + '?subject=' + subject_encoded + '&body=' + question_encoded_quoted">[reply]</a></p>
</div>
</tal:canedit>
</tal:canorcannot>
</metal:main>
</body>
</html>
2018-10-15 14:49:59 ERROR Zope.SiteErrorLog 1539632999.540.786765531231 http://localhost:8080/Plone/questions/question/question_view
Traceback (innermost last):
Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module Shared.DC.Scripts.Bindings, line 322, in __call__
Module Shared.DC.Scripts.Bindings, line 359, in _bindAndExec
Module Products.PageTemplates.ZopePageTemplate, line 338, in _exec
Module Products.PageTemplates.ZopePageTemplate, line 435, in pt_render
Module Products.PageTemplates.PageTemplate, line 87, in pt_render
Module zope.pagetemplate.pagetemplate, line 137, in pt_render
Module five.pt.engine, line 98, in __call__
Module z3c.pt.pagetemplate, line 163, in render
Module chameleon.zpt.template, line 261, in render
Module chameleon.template, line 191, in render
Module chameleon.template, line 171, in render
Module 12d9ee2d84c1a28e145555b2b517bfae.py, line 355, in render
Module five.pt.expressions, line 135, in __call__
Module five.pt.expressions, line 126, in traverse
Module zope.traversing.adapters, line 142, in traversePathElement
- __traceback_info__: (None, 'macros')
Module zope.traversing.adapters, line 56, in traverse
- __traceback_info__: (None, 'macros', ('master',))
LocationError: (None, 'macros')
- Expression: "context/main_template/macros/master"
- Filename: /Plone/portal_skins/custom/question_view
- Location: (line 6: col 23)
- Arguments: repeat: {...} (0)
template: <ImplicitAcquisitionWrapper question_view at 0x109e109b0>
modules: <instance - at 0x103bb2fc8>
here: <instance - at 0x10b1b52d8>
user: <ImplicitAcquisitionWrapper - at 0x10a6522d0>
nothing: <NoneType - at 0x7fff9eb2f6a8>
container: <ImplicitAcquisitionWrapper Plone at 0x10bfb9730>
default: <object - at 0x10328aad0>
request: <instance - at 0x10ba3d0e0>
wrapped_repeat: <SafeMapping - at 0x10bac76d8>
traverse_subpath: <list - at 0x10bb44680>
loop: {...} (0)
context: <instance - at 0x10b1b52d8>
translate: <function translate at 0x10c0f6de8>
root: <ImplicitAcquisitionWrapper Zope at 0x109f5b960>
options: {...} (1)
target_language: <NoneType - at 0x7fff9eb2f6a8>