[ZCM] [ZC] 2141/11 Resolve "TALES 'repeat' shouldn't be traversed
with __getattr__ (items is a common var name)"
Collector: Zope Bugs, Features,
and Patches ...
zope-coders-admin at zope.org
Sat Jul 8 01:07:59 EDT 2006
Issue #2141 Update (Resolve) "TALES 'repeat' shouldn't be traversed with __getattr__ (items is a common var name)"
Status Resolved, Zope/feature medium
To followup, visit:
http://www.zope.org/Collectors/Zope/2141
==============================================================
= Resolve - Entry #11 by philikon on Jul 8, 2006 1:07 am
Status: Accepted => Resolved
Fixed in r69033 (2.10) and r69036 (trunk).
________________________________________
= Assign - Entry #10 by philikon on Jul 7, 2006 8:51 am
Status: Pending => Accepted
Supporters added: philikon
I fixed this in my sandbox, will commit after having fixed a related bug in Zope 3 (http://www.zope.org/Collectors/Zope3-dev/667).
________________________________________
= Resubmit - Entry #9 by philikon on Jul 6, 2006 10:00 am
Status: Resolved => Pending
This is indeed a BBB problem. The example ZPT code provided fschulze DOES work in Zope 2.9. Apparently, the 'repeat' variable wasn't a dict or something.
Note that this IS a Zope 2-only problem as Zope 3 only ever traverses dicts, hence this code would work in Zope 3. It doesn't in Zope 2.10, though.
Resubmitting this issue.
________________________________________
= Resolve - Entry #8 by efge on Jul 6, 2006 8:05 am
Status: Pending => Resolved
Actually I'll close and reopen this in the zope 3 collector as tales is now zope 3.
http://www.zope.org/Collectors/Zope3-dev/666
Probably a bug no one will dare touching :)
________________________________________
= Edit - Entry #7 by efge on Jul 6, 2006 7:56 am
Changes: submitter email, edited transcript, revised title, classification (bug => feature)
________________________________________
= 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