← Back to team overview

launchpad-dev team mailing list archive

Re: Best way to fix canonical_url

 

On Thu, 19 Aug 2010 07:52:51 Curtis Hovey wrote:
> On Thu, 2010-08-19 at 07:25 +1200, Tim Penhey wrote:
> > It isn't just in unit tests, but in page tests too.
> > 
> > the TALES expression branch/fmt:link/+edit
> > 
> > gets converted to:
> >   canonical_url(branch, view_name="+edit")
> > 
> > And we do use that type of TALES expression all over the place.
> 
> I think you can pass the vhost (not layer) to the tales formatter. This
> branch/fmt:link:code/+edit

Unfortunately this still hits the same bug.  That gets translated to:

	canonical_url(branch, rootsite="code", view_name="+edit")

However the rootsite override happens after the view lookup, which uses the 
current browser request.

> Menu links do not honour this rule. The menu made the link using the
> __launchpad_facet__ on the view, even if you are using a facet menu that
> implies the links are on the facet's host and should use its layer.
> 
> From the doc test:
> 
> The link can make the URL go to a specific app.
> 
>     >>> login(ANONYMOUS,
> 
>     ...     LaunchpadTestRequest(SERVER_URL='http://code.launchpad.net'))

This fakes being on the code domain, that's right, however none of the 
following tests hit a view that is registered only on a "non-code" domain.

>     >>> print test_tales("pillar/fmt:link:translations", pillar=ubuntu)
> 
>     <a ...http://translations.launchpad.dev/ubuntu...
> 
>     >>> print test_tales("person/fmt:url:feeds", person=mark)
> 
>     http://feeds.launchpad.dev/~mark
> 
>     >>> print test_tales("bug/fmt:url:mainsite", bug=bug)
> 
>     http://launchpad.dev/bugs/1


Tim



Follow ups

References