Missing.Value object causes error in translation machinery

Bug #649343 reported by Joshua LaPlace on 2010-09-27
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
z3c.pt
Undecided
Unassigned

Bug Description

Traceback (innermost last):
  Module ZPublisher.Publish, line 127, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 47, in call_object
  Module Products.Five.browser.metaconfigure, line 477, in __call__
  Module z3c.pt.pagetemplate, line 262, in __call__
  Module z3c.pt.pagetemplate, line 136, in render
  Module chameleon.core.template, line 394, in render
  Module chameleon.zpt.template, line 17, in render
  Module chameleon.core.template, line 221, in render
  Module chameleon.core.template, line 374, in cook_and_render
  Module chameleon.core.template, line 209, in cook_and_render
   - __traceback_info__: (<ViewPageTemplateFile /home/josh/enfold_buildout/src/enfold.plone4theme/enfold/plone4theme/browser/proxy_internal.pt>,)
  Module chameleon_1902a4653fc6b052f426bbe6908b1ff067f80e5b, line 259, in render
  Module chameleon.core.template, line 420, in render
  Module five.pt.pagetemplate, line 37, in render_macro
  Module chameleon.zpt.template, line 22, in render_macro
  Module chameleon.core.template, line 231, in render_macro
  Module chameleon.core.template, line 374, in cook_and_render
  Module chameleon.core.template, line 209, in cook_and_render
   - __traceback_info__: (<FSPageTemplate /home/josh/enfold_buildout/src/enfold.plone4theme/enfold/plone4theme/skins/enfold_plone4theme_custom_templates/main_template.pt>,)
  Module chameleon_1902a4653fc6b052f426bbe6908b1ff067f80e5b, line 75, in _callback_content_core
  Module z3c.pt.pagetemplate, line 125, in translate
  Module chameleon.core.i18n, line 20, in fast_translate
  Module zope.i18n, line 128, in translate
  Module zope.i18n.translationdomain, line 80, in translate
  Module zope.i18n.translationdomain, line 131, in _recursive_translate
  Module zope.i18n.gettextmessagecatalog, line 56, in queryMessage
  Module gettext, line 400, in ugettext
RuntimeError: Caught exception rendering template.
 - Expression: ``here/main_template/macros/master``
 - Filename: /home/josh/enfold_buildout/src/enfold.plone4theme/enfold/plone4theme/browser/proxy_internal.pt
 - Arguments: context: <ImplicitAcquisitionWrapper 6.0 at 0xd1c639c>
               exists: <function evaluate_exists at 0xc14379c>
               views: <ViewMapper - at 0x1130940c>
               modules: <instance - at 0xa89d4ac>
               here: <ImplicitAcquisitionWrapper 6.0 at 0xd1c639c>
               user: <ImplicitAcquisitionWrapper - at 0xd1df8c4>
               nothing: <NoneType - at 0x822df58>
               path: <function evaluate_path at 0xc143764>
               container: <ImplicitAcquisitionWrapper 6.0 at 0xd1c639c>
               xincludes: <XIncludes - at 0xfb1012c>
               request: <instance - at 0x111e23cc>
               macros: <Macros - at 0x1130f56c>
               template: <ViewPageTemplateFile - at 0xfb09d8c>
               target_language: en
               root: <ImplicitAcquisitionWrapper Zope at 0xc94ed24>
               options: {...} (1)
               view: <SimpleViewClass from /home/josh/enfold_buildout/src/enfold.plone4theme/enfold/plone4theme/browser/proxy_internal.pt enfoldproxyinternalpage at 0x112fe8ec>

RuntimeError: Caught exception rendering template.
 - Expression: ``nothing``
 - Filename: /home/josh/enfold_buildout/src/enfold.plone4theme/enfold/plone4theme/skins/enfold_plone4theme_custom_templates/main_template.pt
 - Arguments: same_type: <function same_type at 0xa429f0c>
               string: <module string at 0xb7d0068cL>
               sequence: <module DocumentTemplate.sequence at 0xa31e8cc>
               random: <module random at 0xb7d009ecL>
               DateTime: <classobj DateTime at 0xa32829c>
               whrandom: <module random at 0xb7d009ecL>
               macros: <Macros - at 0x116e048c>
               reorder: <function reorder at 0xa434cdc>
               sets: <module sets at 0xa31ea04>
               test: <function test at 0xa434c34>
               math: <module math at 0xb7d00be4L>

TypeError: unhashable type: 'Missing.Value'

This is where I found that the error occurred:
<li class="" tal:attributes="class item/selected|nothing">

Item is a catalog brain and item/selected evaluated to Missing.Value. I think that Missing.Value should be treated as False in such tests. Also I was wondering if the translation machinery should be trying to translate the class attribute on a tag?

Ross Patterson (rossp) wrote :

I can confirm that this exception is raised under Chameleon and not raised without Chameleon.

Hanno Schlichting (hannosch) wrote :
Ross Patterson (rossp) wrote :

Is Missing 2.13.1 compatible with Zope 2.12?

Ross Patterson (rossp) wrote :

Actually I spoke too soon, it was with Missing 2.13.1 that I was able to reproduce this error.

Ross Patterson (rossp) wrote :

Add some test coverage that Missing.MV, used for missing values in
Products.ZCatalog, can be used in templates without raising errors.

This was an attempt to resolve LP#649343 but I discovered that the
template which was causing the error was using zope.app.pagetemplate
instead of Products.Five.browser.pagetemplatefile. Once I switched I
no longer for the MissingValue error so the ticket seems to be invalid
or at least I can no longer reproduce it. No harm in preserving the
test coverage though.

Ross Patterson (rossp) wrote :

Scratch that last comment, I was finally able to reproduce the bug in r117828. So this is, in fact, a bug even with Missing 2.13.1.

Malthe mentioned that five.pt had a translate function where I could special-case MissingValue, but I could find no such function in five.pt.

Malthe Borch (mborch) wrote :

Sorry.

z3c/pt/pagetemplate.py:91 (def translate ...)

That's Zope 3 of course and we don't have that Missing class available there in general. One fix might be to conditionally try and import the object and just make it up otherwise. Something like that?

Ross Patterson (rossp) wrote :

That would work if you're not a purist about the test coverage being in a different package than the fix. Want me to go ahead?

Ross Patterson (rossp) wrote :

Test coverage committed in five.pt and fix committed in z3c.pt

Changed in z3c.pt:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers