[z3-five] Can't call absolute_url on a z3 view in z2.10

Philipp von Weitershausen philipp at weitershausen.de
Sun Jun 24 10:36:29 CEST 2007


Derek Richardson wrote:
> In z3, I can call absolute_url on a z3 view in a zpt, like so:
> 
> view/@@absolute_url

The same should work in Zope 2, *if* you have an appropriate 
"absolute_url" view reqistered for BrowserViews. Unfortunately, the 
current implementation in Products.Five.browser.absoluteurl kinda 
depends on the absolute_url() method being there (see below for that). 
It shouldn't be registered for *, really, but for something like 
OFS.interfaces.ITraversable (or whichever interface in Zope 2 defines 
absolute_url).

> Adjusting for z2 vs z3 nomenclature, I should be able to do this in z2.10:
> 
> string:${view/absolute_url}

This is not just a change in nomenclature, it's actually doing something 
very different. The @@ forces view lookup, whereas here you're calling a 
method. Normally this used to be ok in Zope 2 because all objects are 
pretty much required to have a loadfull of methods, one of which is 
absolute_url (hence we ended up in mixin class hell). Five browser views 
simply don't have that method.


-- 
http://worldcookery.com -- Professional Zope documentation and training


More information about the z3-five mailing list