KeyError: 'view_method' with slides.html

Bug #125553 reported by Samuel Schluep
2
Affects Status Importance Assigned to Milestone
Silva dLCMS
In Progress
High
Jasper Op de Coul
Nominated for Trunk by Gerry C.

Bug Description

I created a dLCMS Learning Unit (id is "lu") and inside I added two dLCMS Slides ("slide1" and "slide2"). The slides.html view works as expected, but Zope's console window prints KeyError: 'view_method', see below. Is this ok or should this be fixed? (Silva dLCMS 1.6, Zope 2.8.5-final, python 2.3.5, win32)

2007-05-25 14:52:41 ERROR root Exception while rendering an error message
Traceback (most recent call last):
  File "E:\prog\Zope-2.8.5-final\lib\python\OFS\SimpleItem.py", line 211, in raise_standardErrorMessage
    v = s(**kwargs)
  File "E:\prog\Zope-2.8.5-final\lib\python\Shared\DC\Scripts\Bindings.py", line 311, in __call__
    return self._bindAndExec(args, kw, None)
  File "E:\prog\Zope-2.8.5-final\lib\python\Shared\DC\Scripts\Bindings.py", line 348, in _bindAndExec
    return self._exec(bound_data, args, kw)
  File "E:\prog\Zope-2.8.5-final\lib\python\Products\PageTemplates\ZopePageTemplate.py", line 256, in _exec
    result = self.pt_render(extra_context=bound_names)
  File "E:\prog\Zope-2.8.5-final\lib\python\Products\PageTemplates\PageTemplate.py", line 104, in pt_render
    tal=not source, strictinsert=0)()
  File "E:\prog\Zope-2.8.5-final\lib\python\TAL\TALInterpreter.py", line 206, in __call__
    self.interpret(self.program)
  File "E:\prog\Zope-2.8.5-final\lib\python\TAL\TALInterpreter.py", line 250, in interpret
    handlers[opcode](self, args)
  File "E:\prog\Zope-2.8.5-final\lib\python\TAL\TALInterpreter.py", line 426, in do_optTag_tal
    self.do_optTag(stuff)
  File "E:\prog\Zope-2.8.5-final\lib\python\TAL\TALInterpreter.py", line 411, in do_optTag
    return self.no_tag(start, program)
  File "E:\prog\Zope-2.8.5-final\lib\python\TAL\TALInterpreter.py", line 406, in no_tag
    self.interpret(program)
  File "E:\prog\Zope-2.8.5-final\lib\python\TAL\TALInterpreter.py", line 250, in interpret
    handlers[opcode](self, args)
  File "E:\prog\Zope-2.8.5-final\lib\python\TAL\TALInterpreter.py", line 677, in do_condition
    self.interpret(block)
  File "E:\prog\Zope-2.8.5-final\lib\python\TAL\TALInterpreter.py", line 250, in interpret
    handlers[opcode](self, args)
  File "E:\prog\Zope-2.8.5-final\lib\python\TAL\TALInterpreter.py", line 426, in do_optTag_tal
    self.do_optTag(stuff)
  File "E:\prog\Zope-2.8.5-final\lib\python\TAL\TALInterpreter.py", line 411, in do_optTag
    return self.no_tag(start, program)
  File "E:\prog\Zope-2.8.5-final\lib\python\TAL\TALInterpreter.py", line 406, in no_tag
    self.interpret(program)
  File "E:\prog\Zope-2.8.5-final\lib\python\TAL\TALInterpreter.py", line 250, in interpret
    handlers[opcode](self, args)
  File "E:\prog\Zope-2.8.5-final\lib\python\TAL\TALInterpreter.py", line 711, in do_useMacro
    self.interpret(macro)
  File "E:\prog\Zope-2.8.5-final\lib\python\TAL\TALInterpreter.py", line 250, in interpret
    handlers[opcode](self, args)
  File "E:\prog\Zope-2.8.5-final\lib\python\TAL\TALInterpreter.py", line 481, in do_setGlobal_tal
    self.engine.setGlobal(name, self.engine.evaluateValue(expr))
  File "E:\prog\Zope-2.8.5-final\lib\python\Products\PageTemplates\TALES.py", line 221, in evaluate
    return expression(self)
  File "E:\prog\Zope-2.8.5-final\lib\python\Products\PageTemplates\Expressions.py", line 185, in __call__
    return self._eval(econtext)
  File "E:\prog\Zope-2.8.5-final\lib\python\Products\PageTemplates\Expressions.py", line 173, in _eval
    ob = self._subexprs[-1](econtext)
  File "E:\prog\Zope-2.8.5-final\lib\python\Products\PageTemplates\Expressions.py", line 127, in _eval
    ob = restrictedTraverse(ob, path, getSecurityManager())
  File "E:\prog\Zope-2.8.5-final\lib\python\Products\PageTemplates\Expressions.py", line 308, in restrictedTraverse
    o = object[name]
KeyError: 'view_method'

Samuel Schluep (schluep)
Changed in dlcms:
importance: Undecided → High
status: New → Confirmed
Changed in dlcms:
assignee: nobody → jasper-infrae
Revision history for this message
Jasper Op de Coul (jasper-infrae) wrote :

Hmm, I can not reproduce this with the following setup:

Silva: svn 1.6 branch
SilvaLayout: svn 1.6 branch
SilvaDLCMS: svn trunk
SilvaDLCMSLayout: svn trunk

using the dLCMSNavigation skin, or the default skin.
Also tested without SilvaLayout and SilvaDLCMSLayout.

Judging from the traceback, this is happening somewhere in a pagetemplate. It's strange that
the error is not shown in the browser, this probably has to do with the line:
"ERROR root Exception while rendering an error message"
Which suggests that the error occurs while rendering an error.

Which versions are you using, is my setup correct?

Revision history for this message
Samuel Schluep (schluep) wrote :

I am using the same versions. The view_method KeyError occurresin the layout_macro.html in the ZMI of the dLCMS default layout. Something tries to execute this page template with the slides.html view. If this page template is fixed (see bug 152635) or if the default Silva layout_macro.html is used I get another error: Unauthorized: You are not allowed to access 'get_viewable' in this context (see traceback in the attachment).

Changed in dlcms:
status: Confirmed → In Progress
Revision history for this message
Jasper Op de Coul (jasper-infrae) wrote :

Hi Samuel,

I was a bit confused about the setup, but I can trigger the same error now, using the dlcms ZMILayout.

The Unauthorized error is raised with the obj.get_previewable() call in dlcms_get_metadata_element.py.
Normally when this is called the view_method is either 'view' or 'public_preview'.
But with the slides, the view_method is 'public', because the view_method was unknown. This triggers the obj.get_previewable call in the code below:

# Get metadata from the version requested
if view_method == 'view':
    content = obj.get_viewable()
else:
    content = obj.get_previewable()

I traced this back to the following line in layout_macro.html:

global view_method options/view_method | string:public;

I think this should read:

global view_method options/view_method | string:view;

But In bug 152635, you said it did not contain the last or,
and you changed it into |nothing. So I'm a bit confused about this.
I think the correct behaviour would be that if no view_method was supplied, the public view
should be shown, and not the public_preview.

Revision history for this message
Samuel Schluep (schluep) wrote :

You are right, it should be

global view_method options/view_method | string:view;

I first changed it to "| nothing". Then I did take a look at the templates in SilvaDLCMSLayout where I found "| string:public" and checked in the new layout_macro.html with "| string:public". But this is wrong. I changed this in SilvaDLCMS and SilvaDLCMSLayout to "| string:view".

However, the Unauthorized error persists (with the ZMI based layouts and with SilvaDLCMSLayout). This seems to happen in get_metadata_element in the ZMI (not in dlcms_get_metadata_element) when executing the line

content = context.get_viewable()

It seems that the slides view context does not allow to access get_viewable.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.