Strange difference in ViewPageTemplateFile in Plone 5

I encounter a strange difference between Plone 4 and Plone 5 regarding ViewPageTemplateFile usage.

A browser view instantiates a custom ViewPageTemplateFile and returns the rendered result.

  def __call__(self, *args, **kw):

        from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
        template = ViewPageTemplateFile('mytemplate.pt')
        return template.pt_render(dict(context=self.context, request=self.request))

This works in Plone 4.3 but fails in Plone 5...any incompatibility issue I am missing here?
-aj

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 xmldirector.plonecore.browser.connector, line 288, in __call__
  Module zope.pagetemplate.pagetemplate, line 132, in pt_render
  Module five.pt.engine, line 93, 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 028887844688d1dbea0cc9c242cb792d.py, line 204, in render
  Module 726179452b31263715a65b379bdd7510.py, line 971, in render_master
  Module plone.app.layout.globals.layout, line 165, in bodyClass
AttributeError: 'str' object has no attribute 'getId'

 - Expression: "python:plone_layout.bodyClass(template, view)"
 - Filename:   ... egg/Products/CMFPlone/browser/templates/main_template.pt
 - Location:   (line 45: col 28)
 - Source:     ... e="isRTL portal_state/is_rtl;
                              ^
 - Arguments:  repeat: {...} (0)
               context: <ImplicitAcquisitionWrapper file at 0x7f1e2641f780>
               default: <object - at 0x7f1e3a0e7c20>
               request: <instance - at 0x7f1e25ea65f0>
               wrapped_repeat: <SafeMapping - at 0x7f1e24041f18>
               loop: {...} (0)
               template: ace_editor.pt
               nothing: <NoneType - at 0x7b4050>
               translate: <function translate at 0x7f1e223ceb18>
               target_language: <NoneType - at 0x7b4050>

This looks like an error on main_template rather than your custom template.

Perhaps..at least there is a difference between:

class MyView(BrowserView):
  
   template = ViewPageTemplateFile(....)

  def __call__(self):
      return self.template() # BoundPageTemplateFile

and

class MyView(BrowserView):
  
  def __call__(self):
      template = ViewPageTemplateFile(....)
      return template.pt_render()

The bodyClasses() implementation seems to assume the template is always bound using the variant #1.

-aj

Workaround or fix!?

-aj

This bug in plone.app.layout

https://github.com/plone/Products.CMFPlone/issues/1527

is still open and breaking Plone 5.0.5 with various add-ons.

The Travis information for this PR for Plone 5.0 is no longer available.

-aj