[Zope] Resolving a url from a path in a virtual host environment

Pablo Ziliani pablo at decode.com.ar
Thu Oct 19 20:54:08 EDT 2006


Hi guys,

I'm having some trouble tying to get an object from a given path. I'm 
using virtual hosts, so according to Dieter's great documentation[1], 
REQUEST.resolve_url should do it. However no matter how creative I get 
making up urls, I always get a "Different namespace." ValueError.
Looking at the source of resolve_url[2] I can see that it tries to 
ensure being at the same namespace (?) seeing if REQUEST.script is at 
the beginning of the passed url. So the actual problem is that this 
attribute always returns "http://127.0.0.1:8080" in my (2.9.4-final) 
Zope instance, quite independently from my requested url.

So: should I be using some other method instead? (if so, I guess my 
reference is wrong or outdated). Which one?
Do I need any special configuration to make REQUEST.script returns my 
virtual environment?
Any additional suggestion?

In case the real url after apache's rewrite is relevant, PATH_INFO and 
PATH_TRANSLATED are showing something like:
'/VirtualHostBase/http/www.mydomain.com:80/sites/mysite/VirtualHostRoot/foo/bar.py'

TIA,
Pablo

[1] : Quoting 
http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html#c37ac15c11b4:
"Unless your site uses /virtual hosts/ (or the virtual hosting tools for 
a different purpose) restrictedTraverse is almost the inverse of 
absolute_url. [...] The true inverse of absolute_url is the method 
resolve_url of the request object."
[2] 
http://svn.zope.org/Zope/trunk/lib/python/ZPublisher/HTTPRequest.py?rev=68751&view=markup


More information about the Zope mailing list