[ZCM] [ZC] 2141/ 6 Resubmit "TraversalError with repeat variable access in tal"

Collector: Zope Bugs, Features, and Patches ... zope-coders-admin at zope.org
Thu Jul 6 07:54:08 EDT 2006


Issue #2141 Update (Resubmit) "TraversalError with repeat variable access in tal"
 Status Pending, Zope/bug medium
To followup, visit:
  http://www.zope.org/Collectors/Zope/2141

==============================================================
= Resubmit - Entry #6 by efge on Jul 6, 2006 7:54 am

 Status: Rejected => Pending

I'll reopen to keep this as feature request.

And no, it didn't work either before 2.10 ("repeat" has always been a dict and people have been having this very "items" problem since the beginning).

________________________________________
= Reject - Entry #5 by chrisw on Jul 6, 2006 5:43 am

 Status: Pending => Rejected

I'm not convinced this did work having experienced similar problems in the past.

Even so, it's a silly name to use in a page template, change it ;-)


________________________________________
= Comment - Entry #4 by fschulze on Jul 6, 2006 5:17 am

But it's a regression, it worked in Zope < 2.10.
________________________________________
= Comment - Entry #3 by efge on Jul 5, 2006 8:25 pm

Don't call your variable "items". "repeat" is a dict, "repeat/items" is the "items" method of the dict.

Ok, maybe "repeat" should not be a dict and be traversed specially (with only item lookup, not attribute), but that would be an enhancement.

________________________________________
= Comment - Entry #2 by fschulze on Jul 5, 2006 6:36 pm

A simple pagetemplate to reproduce the bug:

<html>
  <head>
    <title tal:content="template/title">The title</title>
  </head>
  <body>
    <ul tal:define="results python:['foo', 'bar']">
      <tal:block tal:repeat="items results">
        <li tal:define="odd repeat/items/odd"
            tal:attributes="class python:test(odd, 'odd', 'even')"
            tal:content="items"> Content </li>
      </tal:block>
    </ul>
  </body>
</html>
________________________________________
= Request - Entry #1 by fschulze on Jul 5, 2006 6:29 pm

When using a tal repeat statement where the variable name is items, like tal:repeat="items getResults" and then a define which tries to get the variable "odd" like tal:define="odd repeat/items/odd" a TraversalError is thrown TraversalError: (<built-in method items of dict object at 0x623ddb0>, 'odd')

I discovered it in Plone 3.0 when I tried to publish the frontpage and the review history macro is called in the view template.

Full Traceback:

Traceback (innermost last):
  Module ZPublisher.Publish, line 115, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 41, 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 195, in _exec
  Module Products.CMFCore.FSPageTemplate, line 134, 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: 'scripts'
  Module zope.tal.talinterpreter, line 271, in __call__
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 885, in do_useMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 532, in do_optTag_tal
  Module zope.tal.talinterpreter, line 517, in do_optTag
  Module zope.tal.talinterpreter, line 512, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 955, in do_defineSlot
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 532, in do_optTag_tal
  Module zope.tal.talinterpreter, line 517, in do_optTag
  Module zope.tal.talinterpreter, line 512, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 855, in do_defineMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 944, in do_defineSlot
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 532, in do_optTag_tal
  Module zope.tal.talinterpreter, line 517, in do_optTag
  Module zope.tal.talinterpreter, line 512, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 855, in do_defineMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 532, in do_optTag_tal
  Module zope.tal.talinterpreter, line 517, in do_optTag
  Module zope.tal.talinterpreter, line 512, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 885, in do_useMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 849, in do_condition
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 885, in do_useMacro
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 849, in do_condition
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 532, in do_optTag_tal
  Module zope.tal.talinterpreter, line 517, in do_optTag
  Module zope.tal.talinterpreter, line 512, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 849, in do_condition
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 818, in do_loop_tal
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 532, in do_optTag_tal
  Module zope.tal.talinterpreter, line 517, in do_optTag
  Module zope.tal.talinterpreter, line 512, in no_tag
  Module zope.tal.talinterpreter, line 346, in interpret
  Module zope.tal.talinterpreter, line 582, in do_setLocal_tal
  Module zope.tales.tales, line 696, in evaluate
   - URL: file:CMFPlone/skins/plone_templates/main_template.pt
   - Line 25, Column 12
   - Expression: <PathExpr standard:'repeat/items/odd'>
   - Names:
      {'container': <PloneSite at /plone>,
       'context': <ATDocument at /plone/front-page>,
       'default': <object object at 0x38b528>,
       'here': <ATDocument at /plone/front-page>,
       'loop': {'items': <Products.PageTemplates.Expressions.PathIterator object at 0x625e2b0>},
       'nothing': None,
       'options': {'args': ()},
       'repeat': {'items': <Products.PageTemplates.Expressions.PathIterator object at 0x625e2b0>},
       'request': <HTTPRequest, URL=http://localhost:8080/plone/front-page/document_view>,
       'root': <Application at >,
       'template': <FSPageTemplate at /plone/document_view used for /plone/front-page>,
       'traverse_subpath': [],
       'user': <PropertiedUser 'admin'>}
  Module zope.tales.expressions, line 217, in __call__
  Module Products.PageTemplates.Expressions, line 121, in _eval
  Module zope.tales.expressions, line 124, in _eval
  Module Products.PageTemplates.Expressions, line 73, in boboAwareZopeTraverse
  Module zope.traversing.adapters, line 164, in traversePathElement
   - __traceback_info__: (<built-in method items of dict object at 0x623ddb0>, 'odd')
  Module zope.traversing.adapters, line 52, in traverse
   - __traceback_info__: (<built-in method items of dict object at 0x623ddb0>, 'odd', [])
TraversalError: (<built-in method items of dict object at 0x623ddb0>, 'odd')
==============================================================



More information about the Zope-Collector-Monitor mailing list