collective / collective.nitf

A Dexterity-based content type inspired on the News Industry Text Format specification
8 stars 3 forks source link

KeyError: 'relatedItems' on content with no related items #6

Closed hvelarde closed 13 years ago

hvelarde commented 13 years ago

seems to me that this field not available all the time; probably is not really a bug:

Traceback (innermost last):
  Module ZPublisher.Publish, line 126, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module Products.PDBDebugMode.runcall, line 70, in pdb_runcall
  Module ZPublisher.Publish, line 46, in call_object
  Module plone.autoform.view, line 48, in __call__
  Module plone.directives.dexterity.form, line 172, in render
  Module five.grok.components, line 134, in render
  Module zope.pagetemplate.pagetemplate, line 113, in pt_render
   - Warning: Macro expansion failed
   - Warning: <type 'exceptions.KeyError'>: 'listing_macro'
  Module zope.tal.talinterpreter, line 271, in __call__
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 888, in do_useMacro
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 533, in do_optTag_tal
  Module zope.tal.talinterpreter, line 518, in do_optTag
  Module zope.tal.talinterpreter, line 513, in no_tag
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 954, in do_defineSlot
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 533, in do_optTag_tal
  Module zope.tal.talinterpreter, line 518, in do_optTag
  Module zope.tal.talinterpreter, line 513, in no_tag
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 858, in do_defineMacro
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 954, in do_defineSlot
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 533, in do_optTag_tal
  Module zope.tal.talinterpreter, line 518, in do_optTag
  Module zope.tal.talinterpreter, line 513, in no_tag
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 954, in do_defineSlot
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 533, in do_optTag_tal
  Module zope.tal.talinterpreter, line 518, in do_optTag
  Module zope.tal.talinterpreter, line 513, in no_tag
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 946, in do_defineSlot
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 533, in do_optTag_tal
  Module zope.tal.talinterpreter, line 518, in do_optTag
  Module zope.tal.talinterpreter, line 513, in no_tag
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 858, in do_defineMacro
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 533, in do_optTag_tal
  Module zope.tal.talinterpreter, line 518, in do_optTag
  Module zope.tal.talinterpreter, line 513, in no_tag
  Module zope.tal.talinterpreter, line 343, in interpret
  Module zope.tal.talinterpreter, line 851, in do_condition
  Module Products.PageTemplates.Expressions, line 205, in evaluateBoolean
  Module zope.tales.tales, line 696, in evaluate
   - URL: /home/hvelarde/plone-py2.6/nitf/src/collective/nitf/content_templates/newsmedia_view.pt
   - Line 40, Column 8
   - Expression: <PathExpr standard:u'context/relatedItems'>
   - Names:
      {'args': (),
       'container': <Container at /Plone/mi-articulo>,
       'context': <Container at /Plone/mi-articulo>,
       'default': <object object at 0x7f0557e314e0>,
       'here': <Container at /Plone/mi-articulo>,
       'loop': {},
       'nothing': None,
       'options': {},
       'repeat': <Products.PageTemplates.Expressions.SafeMapping object at 0xa14ec58>,
       'request': <HTTPRequest, URL=http://localhost:8080/Plone/mi-articulo/newsmedia_view>,
       'root': <Application at >,
       'static': <five.grok.components.ZopeTwoDirectoryResource object at 0xa8ba890>,
       'template': <Products.Five.browser.pagetemplatefile.ViewPageTemplateFile object at 0x895d9d0>,
       'traverse_subpath': [],
       'user': <PropertiedUser 'admin'>,
       'view': <collective.nitf.content.NewsMedia_View object at 0xa5826d0>,
       'views': <Products.Five.browser.pagetemplatefile.ViewMapper object at 0xa668510>}
  Module zope.tales.expressions, line 217, in __call__
  Module Products.PageTemplates.Expressions, line 147, in _eval
  Module zope.tales.expressions, line 124, in _eval
  Module Products.PageTemplates.Expressions, line 94, in trustedBoboAwareZopeTraverse
  Module OFS.Traversable, line 298, in unrestrictedTraverse
   - __traceback_info__: ([], 'relatedItems')
KeyError: 'relatedItems'
hvelarde commented 13 years ago

use the following as a workaround or solution:

    <fieldset id="related-items" tal:condition="context/relatedItems|nothing">
        <legend i18n:translate="">Related items</legend>
        <tal:relateditems tal:content="structure view/w/IRelatedItems.relatedItems/render" />
    </fieldset>
hvelarde commented 13 years ago

seems that this problem was caused by a mis-pinned packages.