[Zope-CMF] Re: __browser_default__ broken in CMF 1.4.x

Yuppie yuppie at zedat.fu-berlin.de
Mon Sep 29 06:04:27 EDT 2003


Hi!


Andy McKay wrote:
>  From what I can tell CMF 1.4x is broken if you try to use 
> __browser_default__ (the interface to use something other than index_html).

Note: This is about CMF HEAD, not CMF 1.4.x .

> The following traversal hook in DynamicType.py breaks 
> __browser_default__ and sends ZPublisher/BaseRequest.py into an infinite 
> loop. Removing this method makes it work just like normal.

Removing the defined Method Aliases using the new Aliases tabs in 
portal_types should do the same. But this is just a workaround.

> This checkin was made by Yuppie and has no doc string or explanation in 
> the cvs checkin. Its from the aliases branch, so I guess its something 
> to do with that ;)

Right.

> Would anyone care to explain what it actually is meant to acheive in 
> English so we can find a better solution?

German would be easier for me, but I'll try it in English ;)

Quoting from CHANGES.txt:

  o DynamicType manipulates 'TraversalRequestNameStack' depending on
    Method Aliases. '(Default)' and 'view' aliases bypass __call__() and
    view() methods on traversal.

I guess the fact you stumbled over this issue has something to do with 
Plone ;)

Grepping through Plone HEAD, I found PloneFolder has a 
__browser_default__ method. Looks like Plone's __browser_default__ does 
something similar to CMF HEAD's __before_publishing_traverse__: 
Manipulating the default view. I can't see right now why exactly this 
leads to an infinite loop. Maybe you could provide further information.


Some words regarding Method Aliases:

Method Aliases are similar to Type Actions in CMF 1.3 . CMF 1.3 Type 
Actions were method names, not absolute urls like now. 'view()' and 
'__call__()' were aliases for methods looked up in Type Actions.

This still works, but only if you don't try to use the full power of 
Expressions. In CMF 1.4 you have to make sure your Action expression is 
parsable by the backwards compatibility hack used in '_getViewFor()'.

CMF HEAD has both:
- Actions for absolute urls including queries and anchors:
   used for links (menu items) and redirects
- Method Aliases for method ids or paths:
   used for publishing traversal

You can combine Method Aliases and Actions, for example:

{ 'aliases': {'edit.html': 'folder_edit_form',
               'view.pdf': 'index_html/html2pdf'}
, 'actions': ( {'id': 'edit',
                'name': 'Edit',
                'action': 'string:${object_url}/edit.html',
                'permissions': (ModifyPortalContent,) },
                {'id': 'pdf',
                'name': 'PDF',
                'action': 'string:${object_url}/view.pdf',
                'permissions': (View,) } )
}


Cheers,

Yuppie





More information about the Zope-CMF mailing list