Ticket #8372 (closed Bug: fixed)

Opened 6 years ago

Last modified 4 years ago

CMFEditions not compatibel with Zope 3 style views

Reported by: jjmurre Owned by: alecm
Priority: minor Milestone: 3.3.5
Component: Versioning Version:
Keywords: CMFEditions Cc:

Description

Using Zope 3 style views as the default view method for an AT contenttype conflicts with CMFEditions versioning.

The problem is in the get_macros skin script. This script assumes that the template object (that is the default view) has a macros attribute. However, Zope 3 style view are based on Products.Five.browser.pagetemplatefile.ViewPageTemplateFile. This class has no macros attribute, resulting in an AttributeError when trying to render a specific version with the version_history_form.pt template.

Traceback (innermost last):

Module ZPublisher.Publish, line 119, in publish Module ZPublisher.mapply, line 88, in mapply Module Products.PDBDebugMode.pdbzope.runcall, line 60, in pdb_runcall Module ZPublisher.Publish, line 42, in call_object Module Shared.DC.Scripts.Bindings, line 313, in call Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec Module Products.CMFCore.FSPageTemplate, line 216, in _exec Module Products.CMFCore.FSPageTemplate, line 155, in pt_render Module Products.PageTemplates.PageTemplate, line 89, in pt_render Module zope.pagetemplate.pagetemplate, line 117, in pt_render

  • Warning: Macro expansion failed
  • Warning: exceptions.KeyError: 'view_macro'

Module zope.tal.talinterpreter, line 271, in call Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 891, in do_useMacro Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 536, in do_optTag_tal Module zope.tal.talinterpreter, line 521, in do_optTag Module zope.tal.talinterpreter, line 516, in no_tag Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 957, in do_defineSlot Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 536, in do_optTag_tal Module zope.tal.talinterpreter, line 521, in do_optTag Module zope.tal.talinterpreter, line 516, in no_tag Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 861, in do_defineMacro Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 957, in do_defineSlot Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 536, in do_optTag_tal Module zope.tal.talinterpreter, line 521, in do_optTag Module zope.tal.talinterpreter, line 516, in no_tag Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 534, in do_optTag_tal Module zope.tal.talinterpreter, line 516, in no_tag Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 949, in do_defineSlot Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 855, in do_condition Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 855, in do_condition Module zope.tal.talinterpreter, line 346, in interpret Module zope.tal.talinterpreter, line 586, in do_setLocal_tal Module zope.tales.tales, line 696, in evaluate

  • URL: file:/home/jan/zope/knmp.im/parts/plone/CMFEditions/skins/CMFEditions/versions_history_form.pt
  • Line 207, Column 6
  • Expression: <PythonExpr here.get_macros(vdata)>
  • Names:

{'container': <PloneSite at /im>,

'context': <Group at /im/groepje>, 'default': <object object at 0xb7ce7528>, 'here': <Group at /im/groepje>, 'loop': {}, 'nothing': None, 'options': {'args': ()}, 'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0xdb9ba8c>, 'request': <HTTPRequest, URL= http://localhost:8080/im/groepje/versions_history_form>, 'root': <Application at >, 'template': <FSPageTemplate at /im/versions_history_form used for /im/groepje>, 'traverse_subpath': [], 'user': <PropertiedUser 'admin'>}

Module Products.PageTemplates.ZRPythonExpr, line 49, in call

  • traceback_info: here.get_macros(vdata)

Module PythonExpr, line 1, in <expression> Module Products.CMFCore.FSPythonScript, line 140, in call Module Shared.DC.Scripts.Bindings, line 313, in call Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec Module Products.CMFCore.FSPythonScript, line 196, in _exec Module None, line 22, in get_macros

  • <FSPythonScript at /im/get_macros used for /im/groepje>
  • Line 22

Module AccessControl.ImplPython, line 686, in guarded_getattr

AttributeError: macros

Change History

comment:1 Changed 6 years ago by jjmurre

Proposed solution =================

Change the rendering of versions in such a way that they use Zope 3 style views.

Change the version_history_form is such a way that is does not user the get_macros skin script anymore. Instead, it should use Zope 3 style view to render a specifice piece of content.

In CMFEditions a Zope 3 style view is created and registered that mimicks the behaviour of get_macros (more or less). Product (package) developers then have the possibility to register their own Zope 3 style view for their specific content-type(s).

comment:2 Changed 4 years ago by alecm

  • Status changed from new to closed
  • Resolution set to fixed

This error has been fixed (see #10120 and #9963). Views which don't have the expected macros (or any macros) will now just show a "Preview not available" message.

Zope3 views can have a macros attribute though (when they are registered with a template), and when they are being used as a default view for content, then should probably define the 'main' or 'content-core' macro to fit with plone standards.

Note: See TracTickets for help on using tickets.