As @zopyx has suggested, the browser view may be the way.
There's a pattern explained here: https://github.com/plone/plone.api/issues/268
Unless I'm misunderstanding how it works, it looks like you would have to register a browser view which could then be called from restricted python.
I know how to do it with a browser view, but I try to avoid it since this is in a theme.
Why? … because the whole point of the theme is to make it possible for everybody to 'use whatever they find there in their own theme', without having to install add-ons etc.
I dont 'need' anything: I am just trying to make something for the community to help with the lack of themes etc. in Plone 5.