Hi folks,

(this is with CMF 1.4.8)

Today I was puzzling over a pretty simple modification to a TALES expression
in the 'view' action in ... /portal_types/Document/manage_editActionsForm.
It worked fine if I viewed a document  at 
but it broke if viewed at
http://localhost:8080/portal/foo .

I simplified the expression until I was able to reproduce the
problem with something as trivial as:


... which should be more or less equivalent to the default setting:


... but instead, I get "NoneType has no attribute 'absolute_url'".
What the heck?

The traceback pointed me to CMFCore.utils._getViewFor(), which looks up the
view action from the type information - but, weirdly, evaluates
it in a brutally restricted expression context, from

def getActionContext( self ):
    data = { 'object_url'   : ''
           , 'folder_url'   : ''
           , 'portal_url'   : ''
           , 'object'       : None
           , 'folder'       : None
           , 'portal'       : None
           , 'nothing'      : None
           , 'request'      : getattr( self, 'REQUEST', None )
           , 'modules'      : SecureModuleImporter
           , 'member'       : None
    return getEngine().getContext( data )

This is in distinction to the "normal" context it gets when building
the actions to show in the CMF UI. This context comes from
CMFCore.Expression.createExprContext() and has useful bindings for
all of that good stuff.

So we have a slightly schizoid situation in which your View action
TALES expression can do all kinds of cool stuff - EXCEPT when it's
used by _getViewFor(). This seems rather stupid to me. 
If this is a deliberate restriction, can anybody explain the rationale? 
Or is it, as I suspect, an oversight?


Paul Winkler
Zope-CMF maillist  -  Zope-CMF@lists.zope.org

See http://collector.zope.org/CMF for bug reports and feature requests

Reply via email to