Ticket #13736 (new Bug)

Opened 3 years ago

plone.app.iterate.browser.info.BaselineInfoViewlet doesn't work for Dexterity content types

Reported by: daniel@… Owned by:
Priority: minor Milestone: 4.x
Component: Unknown Version: 4.3
Keywords: Cc:

Description

After checking out a dexterity content object viewing the existing live version gives an error like this:

  Module ZPublisher.Publish, line 126, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 46, in call_object
  Module Products.Five.browser.metaconfigure, line 476, in __call__
  Module Products.Five.browser.pagetemplatefile, line 125, in __call__
  Module Products.Five.browser.pagetemplatefile, line 59, in __call__
  Module zope.pagetemplate.pagetemplate, line 132, in pt_render
  Module five.pt.engine, line 93, in __call__
  Module z3c.pt.pagetemplate, line 149, in render
  Module chameleon.zpt.template, line 257, in render
  Module chameleon.template, line 190, in render
  Module chameleon.template, line 172, in render
  Module a1b7694778ef216177aa388cdb7286573485d61d.py, line 213, in render
  Module 032e877fdcdf16ddf1ee8db988cd89c3194bfc4b.py, line 1398, in render_master
  Module z3c.pt.expressions, line 61, in render_content_provider
  Module plone.app.viewletmanager.manager, line 155, in render
  Module plone.app.viewletmanager.manager, line 86, in render
  Module ilrt.formalworkflow.browser.info, line 9, in render
  Module plone.memoize.instance, line 51, in memogetter
  Module plone.app.iterate.browser.info, line 110, in working_copy
AttributeError: getBRefs

I have these packages installed:

plone.app.referenceablebehavior
plone.app.iterate
plone.app.stagingbehavior

The dexterity type in question has the referenceable behaviour. I noticed from looking at the source of plone.app.referenceablebehavior that it registers an adapter for IReferenceable that provides the appropriate methods but plone.app.iterate doesn't appear to use it.

Here is a patch that makes it work (note that I've only changed the one method that mattered to me but I assume the others would have the same problem):

--- info_wrong.py	2013-09-16 15:00:51.000000000 +0800
+++ info_right.py	2013-09-16 15:00:40.000000000 +0800
@@ -22,6 +22,8 @@
 from plone.memoize.instance import memoize
 from Products.CMFPlone.log import logger

+from Products.Archetypes.interfaces.referenceable import IReferenceable
+
 class BaseInfoViewlet( BrowserView ):

     implements( IViewlet )
@@ -104,7 +106,7 @@

     @memoize
     def working_copy( self ):
-        refs = self.context.getBRefs( WorkingCopyRelation.relationship )
+        refs = IReferenceable(self.context).getBRefs( WorkingCopyRelation.relationship )
         if len( refs ) > 0:
             return refs[0]
         else:
Note: See TracTickets for help on using tickets.