[ZCM] [ZC] 1568/13 Resolve "VIRTUAL_URL only available if VHM is
used"
Collector: Zope Bugs, Features,
and Patches ...
zope-coders-admin at zope.org
Thu Dec 2 12:10:21 EST 2004
Issue #1568 Update (Resolve) "VIRTUAL_URL only available if VHM is used"
Status Resolved, Zope/bug medium
To followup, visit:
http://collector.zope.org/Zope/1568
==============================================================
= Resolve - Entry #13 by ajung on Dec 2, 2004 12:10 pm
Status: Accepted => Resolved
Patch applied for 2.7.4, 2.8a2
________________________________________
= Comment - Entry #12 by longsleep on Dec 1, 2004 6:36 am
Uploaded: "actual_url.patch"
- http://collector.zope.org/Zope/1568/actual_url.patch/view
New patch which sets the ACTUAL_URL key in base request and inside VirtualHostMonster. This new key can be used to properly generate URLs which have to match the exact browser URL.
________________________________________
= Comment - Entry #11 by ajung on Nov 29, 2004 7:51 am
Explanation: the patch sets VIRTUAL_URL in a vhost and non-vhosted
environment. VHM will override this value on its own.
The name 'VIRTUAL_URL' is somewhat stupid in a non-vhost environment. Either we keep this name or we create a new one which
needs to be added to the VHM code as well.
________________________________________
= Assign - Entry #10 by ajung on Nov 29, 2004 7:49 am
Uploaded: "BaseRequest.patch"
- http://collector.zope.org/Zope/1568/BaseRequest.patch/view
Please check if the attached patch works for you.
________________________________________
= Comment - Entry #9 by efge on Nov 26, 2004 5:20 am
As yuppie pointed out, the resolution of this bug must be by adding a VIRTUAL_URL to REQUEST in all cases, not add a VHM at site init.
________________________________________
= Comment - Entry #8 by efge on Nov 26, 2004 5:16 am
See for more info:
http://mail.zope.org/pipermail/zope-dev/2003-December/021100.html
See also http://collector.zope.org/Zope/1308 Entry #5 where there's an example of the cases where the various variables differ.
________________________________________
= Comment - Entry #7 by yuppie on Nov 26, 2004 3:47 am
AFAICS just adding VHM doesn't resolve this issue. Currently VHM does not add VIRTUAL_URL if the VHM is not *used* (means the URL doesn't contain VirtualHostBase/VirtualHostRoot).
________________________________________
= Assign - Entry #6 by tino on Nov 25, 2004 6:06 pm
Status: Pending => Accepted
Supporters added: tino
In Zope2.7.3:
OFS/Application.py
Line 307:
self.install_virtual_hosting()
Line 501:
def install_virtual_hosting(self):
app = self.getApp()
if app._getInitializerFlag('virtual_hosting'):
return
if not hasattr(app, 'virtual_hosting'):
from Products.SiteAccess.VirtualHostMonster import VirtualHostMonster
vhm=VirtualHostMonster()
vhm.id='virtual_hosting'
vhm.addToContainer(app)
self.commit('Added virtual_hosting')
# This adds virtual_hosting as ID for
# the hostmonster. If this is ok, I can
# check that in
________________________________________
= Comment - Entry #5 by ajung on Nov 20, 2004 11:11 am
Sounds good to me...patches are welcome :-)
________________________________________
= Comment - Entry #4 by limi on Nov 9, 2004 12:18 pm
I have no problem with adding this in Plone, but my point is that it's hard even for a plain Zope developer. But sure, we can do that.
________________________________________
= Comment - Entry #3 by shh on Nov 9, 2004 11:49 am
+1 for adding VHM. But call it "virtual_host_monster" or "virtual_hosting".
________________________________________
= Comment - Entry #2 by Tiran on Nov 9, 2004 11:21 am
I'm voting for adding a VHM with id "VirtualHostMonster" at startup of Zope so we alway have a VHM in the root folder. It's causing no harm and the benefits are great. Also it would solve the issue with only few lines of code in the startup code. People could depend on the existince of a VHM which is great. :)
For example:
Very often I've the problem that I have to setup a Zope server on a remote server that is firewalled. I'm not allowed to access Zope ports and I've already added the VHM magic to the rewrite rules in the apache.conf. It's very annoying to add a VHM with links/lynx.
________________________________________
= Request - Entry #1 by limi on Nov 9, 2004 10:01 am
Sorry for entering this as a new bug, bug the Collector doesn't allow me to re-open http://collector.zope.org/Zope/1252
The short summary is that there's no good way of getting the URL of the current page (ie. what it actually says in the URL field) as opposed to what Zope reports as the object URL.
This was supposed to be fixed with the introduction of VIRTUAL_URL (which is a sily name, I agree) - the problem is that this has no fallback value when VirtualHostMonster isn't being used in a site - which makes it impossible to rely on this in product code - which kind of negates the whole idea of having it there.
Would it be possible to let Zope return a sane value instead of causing a traceback when there is no VHM present?
Sorry to be so persistent about this, but it's one of the things that truly suck as a newbie developer with Zope and Plone - the fact that getting the *current URL you're at* is almost impossible. I do not think this code to create a simple anchor (#) that always works is obvious to people:
<a tal:define="url request/VIRTUAL_URL|string:${request/SERVER_URL}${request/PATH_TRANSLATED}" tal:attributes="href string:${url}#someContent">
Skip to content
</a>
==============================================================
More information about the Zope-Collector-Monitor
mailing list