[ZCM] [ZC] 2156/ 5 Comment "Metal: error using macroname 'update'"

Collector: Zope Bugs, Features, and Patches ... zope-coders-admin at zope.org
Fri Jul 21 13:07:04 EDT 2006


Issue #2156 Update (Comment) "Metal: error using macroname 'update'"
 Status Wontfix, Zope/bug medium
To followup, visit:
  http://www.zope.org/Collectors/Zope/2156

==============================================================
= Comment - Entry #5 by philikon on Jul 21, 2006 1:07 pm

In Zope 2 (at least 2.8 and 2.9), TALES traversal handles dicts just like any other object. That means, attribute access *before* item access. That also means, any dict method (items, keys, etc.) will shadow items inside the dict.

Zope 3 special cases dicts (and only dicts!) during TALES traversal. This is a known fact and indeed a (wanted) difference between Zope 2 and Zope 3 (not the difference is wanted, but the Zope 2 behaviour is apparently needed for backward compatibility and Zope 3 wants the speed optimization from the special casing of dicts).
________________________________________
= Comment - Entry #4 by d2m on Jul 21, 2006 1:02 pm

there is no error wit zope2.7
the error message from zope2.8 is clearer: 
  Error Value: update() takes exactly one argument (0 given)
zope2.9 error message is a bit misleading:
  TypeError: len() of unsized object
zope3.2 happily accepts 'update' as a macro name

if 'macros' is a dict, why is update() shadowing a dictionary key ? shouldn't this be enforced in the expression compiler ?

which other methods will shadow possible dictionary keys ?

why is this not documented (in source at least) ?

________________________________________
= Edit - Entry #3 by tseaver on Jul 21, 2006 12:43 pm

 Changes: submitter email, edited transcript, new comment

'macros' is always a dict.
________________________________________
= Wontfix - Entry #2 by tseaver on Jul 21, 2006 12:35 pm

 Status: Pending => Wontfix

The 'macros' of a template is a dict, whose 'update' method shadows any key named update when used in a path expression.

As a workaround, try:

  <div metal:use-macro="template.macros['update']" />

Better yet, rename the macro.
________________________________________
= Request - Entry #1 by d2m on Jul 21, 2006 12:14 pm

Using 'update' as a metal macroname throws an error

==master==
<div metal:use-macro="context/detail/macros/update" />

==detail==
before <div metal:define-macro="update">text</div> after

--traceback--
2006-07-21 17:50:28 ERROR Zope.SiteErrorLog http://host/temp_folder/master
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 311, in __call__
  Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec
  Module Products.PageTemplates.ZopePageTemplate, line 256, in _exec
  Module Products.PageTemplates.PageTemplate, line 104, in pt_render
   - <ZopePageTemplate at /temp_folder/master>
  Module TAL.TALInterpreter, line 238, in __call__
  Module TAL.TALInterpreter, line 281, in interpret
  Module TAL.TALInterpreter, line 739, in do_useMacro
  Module TAL.TALDefs, line 152, in isCurrentVersion
  Module TAL.TALDefs, line 165, in getProgramVersion
TypeError: len() of unsized object

==============================================================



More information about the Zope-Collector-Monitor mailing list