[EuroPython] How do you make links go from the pulldown menus directly off the site?

Jean-Marc Orliaguet jmo at ita.chalmers.se
Mon Feb 14 13:26:22 CET 2005


Chris Withers wrote:

> Jean-Marc Orliaguet wrote:
>
>> The whole thing is about fixing a UI weirdness. A navigation menu is 
>> not designed in the first place to redirect the user to another site 
>> without warning - it makes the interaction with the site 
>> unpredictable - so I believe that it is a good thing that the current 
>> menu doesn't allow those kinds of links. For that functionality you 
>> should use a box marked as "External links"... or integrate the wiki 
>> inside the site.
>
>
> *shrugs* I can empathise with this point of view but I don't agree 
> with it.
>
> A navigation menu is for navigating. If some of the resources are not 
> at the current domain name, then they need an "external link". Can it 
> be that hard to do something like:
>
> tal:attributes="href 
> python:test(getattr(item,'external',none),item.url,item.absolute_url())"
>
> Chris
>

Hi Chris,
this is not very effective in terms of performance.

test(condition, A, B) evaluates all three values no matter the result of 
the test, i.e.
- getattr(item,'external',none)
- item.url
- item.absolute_url()

so even if 'getattr(item,'external',none)' is  false, item.url will be 
evaluate which will cause an AttributeError exception.

then getattr(item, 'external', none) is not acquisition-safe so there is 
a risk that you will get an attribute of the container object.

the current implementation instead fetches the menu items directly from 
the tree cache without getting to the items themselves, which is much 
more efficient.

the url rewrite should be placed in the Apache configuration instead.

/JM


More information about the EuroPython mailing list