I try to get context object in IPubAfterTraversal hook from event
@grok.subscribe(IPubAfterTraversal)
def admin_language_negotiator(event):
"""
Event handler which pokes the language after traversing and authentication is done, but before rendering.
"""
# Keep the current request language (negotiated on portal_languages)
# untouched
request = event.request
if not IAddonSpecific.providedBy(request):
# Add on is not active
return
context = request.get("PUBLISHED", None)
I’d like to do:
IContentish.providedBy(context) # Check if real content request or CSS/Image request
PUBLISHED is not content item context, however:
context
<FSPageTemplate at /Plone/en/plan/plan/document_view>
The PUBLISHED may or may not point to a view. What is the safest way to get published content item object, if any, out of HTTPRequest?
plone.app.theming does it like this:
https://github.com/plone/plone.app.theming/blob/master/src/plone/app/theming/utils.py#L146