VIRTUAL_URL

Bug #142909 reported by yuppie
2
Affects Status Importance Assigned to Milestone
Zope 2
Invalid
Medium
Unassigned

Bug Description

On Zope-CMF Alexander Limi wrote:
[...]
> I investigate the options i have, noting that no variable seems to keep
> the actual URL that is *inside the fecking URL bar* in my browser.
>
> I turn to Simon Eisenmann for help, he comes up with an idea of using a
> combination of SERVER_URL and PATH_TRANSLATED to construct the actual
> URL we're at.
>
> But guess what? This doesn't work in Virtual Hosting scenarioes. So we
> have to create an additional rule that gets rendered if you have a
> Virtual Hosted system.
>
> The rule ends up looking like this:
>
> <a
> tal:define="url
> request/VIRTUAL_URL|string:${request/SERVER_URL}${request/PATH_TRANSLATED}"
> tal:attributes="href string:${url}#someContent"
>
>> Skip to content</a>
>
>
> Easy, right?
[...]

I think this is a bug. VIRTUAL_URL should always be available. This would make it much easier to use:

  <a tal:attributes="href string:${request/VIRTUAL_URL}#someContent"
  > Skip to content</a>

Tags: bug zope
Revision history for this message
ChrisW (chris-simplistix) wrote :

While I'm tempted just to out-and-out reject this, my name isn't Andreas ;-)

Why not just use here/absolute_url or container/absolute_url, depending on what it is you actually want to do?

Any code that uses a fixed string URL like SERVER_URL or VIRTUAL_URL is gonna be pretty fragile...

Revision history for this message
yuppie (yuppie3) wrote :

@ chrisw:

See my request
<http://mail.zope.org/pipermail/zope-dev/2003-December/021100.html>
and Casey's reply
<http://mail.zope.org/pipermail/zope-dev/2003-December/021101.html>
for reasons why Evan added VIRTUAL_URL in Zope 2.7.

absolute_url() does not return the same URL. VIRTUAL_URL works fine if you have a VHM.

Revision history for this message
ChrisW (chris-simplistix) wrote :

Why on earth did it end up being called VIRTUAL_URL?

I still don't really see the usecase for this, but the functionality is there, so I'll just keep quiet...

Revision history for this message
Andreas Jung (ajung) wrote :

Similiar issue: #1308

Revision history for this message
ChrisW (chris-simplistix) wrote :

Status: Pending => Resolved

It would appear Evan added this functionality in Zope 2.7, so this is resolved.

Revision history for this message
yuppie (yuppie3) wrote :

This is *not* resolved. In Zope 2.7 VIRTUAL_URL was added, but it is only available if a VHM exists. This makes it hard to write code that works with and without a VHM.

Revision history for this message
ChrisW (chris-simplistix) wrote :

Since adding a vhm has no negative impact, I'd say adding a vhm is the "right" thing to do t osolve your problem.

Revision history for this message
yuppie (yuppie3) wrote :

Oops. My last comment was not correct. The fact a VHM exists is not enough. It has to be used.

My point is that you have to be very careful if you use VIRTUAL_URL in a product because you can't be sure a VHM is used.

BTW: Issue #1308 is very similar to this one. I don't agree with the reasons why it was rejected either.

Revision history for this message
Florent Guillaume (efge) wrote :

Status: Resolved => Rejected

This bug is valid but is now worked on in
http://zope.org/Collectors/Zope/1568

So rejecting as dupe.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.