How to enable versioning and diffing properly for custom content-types?

We have a DX-based folderish type with versioning behavior enabled (Plone 5.2.2).

The "change note" is visible and the versioning history view is also available.
However there is only a "View" button but nothing for "Compare" or "Revert".

Anything missing here? Our folder type has a bunch of additional metadata over the standard Folder type.

There is also an issue with the "View" functionality

Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 162, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 359, in publish_module
  Module ZPublisher.WSGIPublisher, line 254, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZPublisher.WSGIPublisher, line 63, in call_object
  Module Shared.DC.Scripts.Bindings, line 335, in __call__
  Module Shared.DC.Scripts.Bindings, line 372, in _bindAndExec
  Module Products.CMFCore.FSPageTemplate, line 256, in _exec
  Module Products.CMFCore.FSPageTemplate, line 196, in pt_render
  Module Products.PageTemplates.PageTemplate, line 83, in pt_render
  Module zope.pagetemplate.pagetemplate, line 133, in pt_render
  Module Products.PageTemplates.engine, line 367, in __call__
  Module z3c.pt.pagetemplate, line 176, in render
  Module chameleon.zpt.template, line 307, in render
  Module chameleon.template, line 192, in render
  Module b9d19545d74e778c07647b3713addeda, line 2180, in render
  Module 258b65442db4ad28926e0961385d0bae, line 860, in render_master
  Module 258b65442db4ad28926e0961385d0bae, line 1480, in render_content
  Module b9d19545d74e778c07647b3713addeda, line 1859, in __fill_main
  Module zope.tales.expressions, line 250, in __call__
  Module Products.PageTemplates.Expressions, line 196, in _eval
  Module Products.PageTemplates.Expressions, line 126, in render
  Module plone.app.versioningbehavior.browser, line 50, in __call__
  Module plone.autoform.view, line 42, in __call__
  Module plone.autoform.view, line 33, in render
  Module Products.Five.browser.pagetemplatefile, line 126, in __call__
  Module Products.Five.browser.pagetemplatefile, line 58, in __call__
  Module zope.pagetemplate.pagetemplate, line 133, in pt_render
  Module Products.PageTemplates.engine, line 367, in __call__
  Module z3c.pt.pagetemplate, line 176, in render
  Module chameleon.zpt.template, line 307, in render
  Module chameleon.template, line 214, in render
  Module chameleon.utils, line 75, in raise_with_traceback
  Module chameleon.template, line 192, in render
  Module 79f49b171726595dafb8020515be3ccd, line 543, in render
  Module 79f49b171726595dafb8020515be3ccd, line 455, in render_content_core
  Module 39693c9060f8ba7450e2eaefee86177d, line 390, in render_listing
  Module zope.tales.expressions, line 250, in __call__
  Module Products.PageTemplates.Expressions, line 188, in _eval
  Module zope.tales.expressions, line 153, in _eval
  Module Products.PageTemplates.Expressions, line 104, in trustedBoboAwareZopeTraverse
  Module zope.traversing.adapters, line 156, in traversePathElement
   - __traceback_info__: (<Products.Five.browser.metaconfigure.SimpleViewClass from /home/ajung/sandboxes/ugent-portaal-plone-4x/eggs/plone.dexterity-2.9.7-py3.8.egg/plone/dexterity/browser/containercontentcore.pt object at 0x7f39305d46d0>, 'batch')
  Module zope.traversing.adapters, line 61, in traverse
   - __traceback_info__: (<Products.Five.browser.metaconfigure.SimpleViewClass from /home/ajung/sandboxes/ugent-portaal-plone-4x/eggs/plone.dexterity-2.9.7-py3.8.egg/plone/dexterity/browser/containercontentcore.pt object at 0x7f39305d46d0>, 'batch', [])
zope.location.interfaces.LocationError: zope.location.interfaces.LocationError: (<Products.Five.browser.metaconfigure.SimpleViewClass from /home/ajung/sandboxes/ugent-portaal-plone-4x/eggs/plone.dexterity-2.9.7-py3.8.egg/plone/dexterity/browser/containercontentcore.pt object at 0x7f39305d46d0>, 'batch')

 - Expression: "view/batch"
 - Filename:   ... .egg/plone/app/contenttypes/browser/templates/listing.pt
 - Location:   (line 22: col 31)
 - Source:     <tal:results define="batch view/batch;
                                          ^^^^^^^^^^
 - Expression: "listing_macro"
 - Filename:   ... y3.8.egg/plone/dexterity/browser/containercontentcore.pt
 - Location:   (line 24: col 38)
 - Source:     ... metal:use_macro use-macro="listing_macro" />
                                              ^^^^^^^^^^^^^
 - Expression: "context/main_template/macros/master"
 - Filename:   ... s/CMFEditions/skins/CMFEditions/versions_history_form.pt
 - Location:   (line 1: col 23)
 - Source:     ... l:use-macro="context/main_template/macros/master" i18n:domai ...
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 - Arguments:  template: <Products.Five.browser.pagetemplatefile.ViewPageTemplateFile object at 0x7f3931d221c0>
               options: {}
               args: ()
               nothing: None
               modules: <Products.PageTemplates.ZRPythonExpr._SecureModuleImporter object at 0x7f3942ad12e0>
               request: <WSGIRequest, URL=http://dev2.zopyx.de:20081/Plone/x1/versions_history_form>
               view: <Products.Five.browser.metaconfigure.SimpleViewClass from /home/ajung/sandboxes/ugent-portaal-plone-4x/eggs/plone.dexterity-2.9.7-py3.8.egg/plone/dexterity/browser/containercontentcore.pt object at 0x7f39305d46d0>
               context: <SubsiteFolder at /Plone/x1>
               views: <Products.Five.browser.pagetemplatefile.ViewMapper object at 0x7f39303cb550>
               here: <SubsiteFolder at /Plone/x1>
               container: <SubsiteFolder at /Plone/x1>
               root: <Application at >
               traverse_subpath: []
               user: <PropertiedUser 'admin'>
               default: <DEFAULT>
               repeat: <Products.PageTemplates.engine.RepeatDictWrapper object at 0x7f393071abc0>
               loop: {'widget': <Products.PageTemplates.engine.RepeatItem object at 0x7f39314a7850>, 'group': <Products.PageTemplates.engine.RepeatItem object at 0x7f39308d6d60>}
               target_language: None
               translate: <function BaseTemplate.render.<locals>.translate at 0x7f39308b18b0>

I think I have seen this with 'very basic basic content types as well.

I have a site with the same behaviour, where I noticed that I can actually revert by clicking on the version and then get a revert button

In other words, an url like this:

/versions_history_form?version_id=3

Content types must be registered in portal_diff in order to use "compare" and "diff".

I think this should/must be handled by Plone automatically when abou enable/disable the versioning behavior.

But wait there is also a versioning option per content-type in the content-type settings of Plone. Is this setting conflicting or supplementary to the versioning behavior?!

afaik setting versioning for the content type after enabling the behavior is enough.
I normally set it to 'automatic'.

This is possibly true when you do this manually. But this does not seem to be the case when you create a site and all the setup programmatically.

For on filesystem content types you can add repositorytool.xml with a versioning policy:

<?xml version="1.0"?>
<repositorytool>
 <policymap purge="false">
  <type name="MyContentType">
   <policy name="at_edit_autoversion"/>
   <policy name="version_on_revert"/>
  </type>
 </policymap>
</repositorytool>

difftool.xml for the diffing strategy:

<?xml version="1.0"?>
<object>
 <difftypes purge="false">
  <type portal_type="MyContentType">
   <field name="any" difftype="Compound Diff for Dexterity types"/>
  </type>
  </difftypes>
</object>

And the third thing I sometimes forget with custom content types is to check & add the catalog indexing of fields, especially the text fields for the SearchableText index, most of the time we use collective.dexteritytextindexer for those.

1 Like

Not sure if I misunderstand here, but this what I think:

  1. Someone adds a new Content Type TTW and enables a rich text field or rich text behavior.
  2. "Versioning is enabled" as a behavior for that Content type
  3. "Someone" expect this to be enough.

That approach does not work (at least not in my setup).

If that is not the case, it would be nice if the description of versioning was different than:

 Versioning support with CMFEditions

Maybe:

Versioning support with CMFEditions. NOTE! you also need to do A and B <a href="/link_to_doc">Read more here</a>

PS: I think it is possible to use links in the description

1 Like