ACTUAL_URL is not actual URL ;)

Bug #143465 reported by Alexander Limi
2
Affects Status Importance Assigned to Milestone
Zope 2
Opinion
Medium
Unassigned

Bug Description

This is a follow-up to http://www.zope.org/Collectors/Zope/1568

The new ACTUAL_URL variable is 95% there, but doesn't include the query string of the URL, which it has to do to solve the use case for why ACTUAL_URL was invented in the first place: HTML anchors.

Please do not invent yet another variable for this, but add the query string to ACTUAL_URL. The other variations needed can be constructed from the existing elements, this is a convenience method for developers who need to render the URL currently shown in the URL bar.

(And if you *do* invent another variable, please make ACTUAL_URL include the query string and find another name for the one without the query string. ;)

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

Patches are welcome :-)

Revision history for this message
yuppie (yuppie3) wrote :

Before we add yet another variable, could you please test if this code has the desired behavior:

  <a tal:define="actual_query python:request['QUERY_STRING'] and '?'+request['QUERY_STRING'] or ''"
     tal:attributes="href string:${request/ACTUAL_URL}${actual_query}#someContent"
  > Skip to content</a>

'URL' variables in REQUEST never include the query string, so I'm not sure if it is a good idea to change ACTUAL_URL. Changing its behavior might also break existing code.

Revision history for this message
yuppie (yuppie3) wrote :

Changes: submitter email, edited transcript, new comment

fixed my last comment: should be ACTUAL_URL, not VIRTUAL_URL

Revision history for this message
Alexander Limi (limi) wrote :

1) If you look at the original use case and reason for introducing ACTUAL_URL, it was to use with anchors, which is why it needs the query string

2) The ACTUAL_URL code has existed for two point releases (introduced in 2.7.4 or 2.7.5), and I can't see how people can rely on it *not* having the query string part. People expect it to, as several bug reports in the Plone Collector has shown - which is why I'm here. ;)

Anyway, a notice in the changelog that it includes the query string should be enough. I doubt anyone has gotten around to including this call in their code yet - and if they have, they probably expect it to solve the anchor use case, which it won't - yet.

Thanks for the code snippet, will test.

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

+1 for including the query string.

Revision history for this message
Alexander Limi (limi) wrote :

I can confirm that the code snippet does the right thing, and gives the *actual* ACTUAL_URL :)

Revision history for this message
yuppie (yuppie3) wrote :

> = Comment - Entry #5 by limi on Jul 18, 2005 12:02 pm
>
> 1) If you look at the original use case and reason for introducing
> ACTUAL_URL, it was to use with anchors, which is why it needs the query
> string

Well. That is *your* use case. VIRTUAL_URL was originally introduced for other use cases. And ACTUAL_URL is nothing special for anchors, it supersedes VIRTUAL_URL for all use cases.

> 2) The ACTUAL_URL code has existed for two point releases (introduced in
> 2.7.4 or 2.7.5), and I can't see how people can rely on it *not* having
> the query string part. People expect it to, as several bug reports in the
> Plone Collector has shown - which is why I'm here. ;)

Meanwhile more Zope versions with ACTUAL_URL are released. And people might have started working around this issue with code like the snippet in #3.

> Anyway, a notice in the changelog that it includes the query string
> should be enough. I doubt anyone has gotten around to including this call
> in their code yet - and if they have, they probably expect it to solve
> the anchor use case, which it won't - yet.

I have code that will break if ACTUAL_URL is changed and I doubt I'm the only one.

-1 for changing the behavior of ACTUAL_URL (at least in a minor release)

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

I agree with Yuppie that we can't change the behaviour for compabitility reasons. If necessary one could build yet another variable ACTUAL_URL_XXXX (think about a new suffix) to implement finally the desired behaviour.

Revision history for this message
Hanno Schlichting (hannosch) wrote :

Ah, I found a good example for an "opinion" ticket :)

Changed in zope2:
status: New → Opinion
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.