Hiding behind Apache - how to get true physical path?
I'm working on a Zope server which is sitting behind Apache, so instead of http://somehost/foo/bar/baz URLs take this form: http://somehost/Zope/foo/bar/baz Inside a Python script I can ask for the path to an object like so: context.foo.getPhysicalPath() which returns ('', 'foo') Is there a way to get it to return ('', 'Zope', 'foo') without knowing "/Zope" explicitly? Thanks, -- Skip Montanaro - skip@pobox.com http://www.mojam.com/ http://www.musi-cal.com/
Would a SiteRoot object do the trick? I've never used it in a script, but it has made Zope behave well behind Apache for me. On Sun, 2002-12-01 at 14:42, Skip Montanaro wrote:
I'm working on a Zope server which is sitting behind Apache, so instead of
URLs take this form:
http://somehost/Zope/foo/bar/baz
Inside a Python script I can ask for the path to an object like so:
context.foo.getPhysicalPath()
which returns
('', 'foo')
Is there a way to get it to return
('', 'Zope', 'foo')
without knowing "/Zope" explicitly?
Thanks,
-- Skip Montanaro - skip@pobox.com http://www.mojam.com/ http://www.musi-cal.com/
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
-- Tim Freund tim@freunds.net
Tim> Would a SiteRoot object do the trick? Thanks for the suggestion. I'll check it out. Skip
You could always get the URLPATH from the request and split it on "/". I'm sure there must be a nicer way to do this still... Skip Montanaro wrote:
I'm working on a Zope server which is sitting behind Apache, so instead of
URLs take this form:
http://somehost/Zope/foo/bar/baz
Inside a Python script I can ask for the path to an object like so:
context.foo.getPhysicalPath()
which returns
('', 'foo')
Is there a way to get it to return
('', 'Zope', 'foo')
without knowing "/Zope" explicitly?
Thanks,
Skip Montanaro writes:
I'm working on a Zope server which is sitting behind Apache, so instead of
URLs take this form:
http://somehost/Zope/foo/bar/baz
Inside a Python script I can ask for the path to an object like so:
context.foo.getPhysicalPath()
which returns
('', 'foo')
Is there a way to get it to return
('', 'Zope', 'foo')
without knowing "/Zope" explicitly? Use VHM (VirtualHostMonster) and "absolute_url" and forget about the question above.
Head the documentation you find on a VHM instance. Dieter
I think the question is how to return a tuple of the path to the object in context (rather than just the physical root path to it) So if 'foo' exists in the root, but you are calling it from inside the 'Zope' object, how can you get a tuple of ('', 'Zope', 'foo'). I suggested just splitting the REQUEST.URLPATH0 and getting it from there. Is there a better way? Dieter Maurer wrote:
Skip Montanaro writes:
I'm working on a Zope server which is sitting behind Apache, so instead of
URLs take this form:
http://somehost/Zope/foo/bar/baz
Inside a Python script I can ask for the path to an object like so:
context.foo.getPhysicalPath()
which returns
('', 'foo')
Is there a way to get it to return
('', 'Zope', 'foo')
without knowing "/Zope" explicitly? Use VHM (VirtualHostMonster) and "absolute_url" and forget about the question above.
Head the documentation you find on a VHM instance.
Dieter
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Chris Beaven writes:
I think the question is how to return a tuple of the path to the object in context (rather than just the physical root path to it)
So if 'foo' exists in the root, but you are calling it from inside the 'Zope' object, how can you get a tuple of ('', 'Zope', 'foo'). I suggested just splitting the REQUEST.URLPATH0 and getting it from there. Is there a better way? When you do it right, there may be no need to know about the "Zope" intermediate URL segment. Personally, I would go for such a solution.
Dieter
If there was a reason (say it was \\somehost\en\homepage vs \\somehost\jp\homepage or something similar) how would you go about figuring out whether en / jp was the language you should be using? It's just an interesting point (what actually got me responding to the original post in the first place) and could be useful for me at some point in time... Chris Dieter Maurer wrote:
Chris Beaven writes:
I think the question is how to return a tuple of the path to the object in context (rather than just the physical root path to it)
So if 'foo' exists in the root, but you are calling it from inside the 'Zope' object, how can you get a tuple of ('', 'Zope', 'foo'). I suggested just splitting the REQUEST.URLPATH0 and getting it from there. Is there a better way? When you do it right, there may be no need to know about the "Zope" intermediate URL segment. Personally, I would go for such a solution.
Dieter
Chris Beaven wrote: [How to get the "real" physical path with vhosting]
If there was a reason (say it was \\somehost\en\homepage vs \\somehost\jp\homepage or something similar) how would you go about figuring out whether en / jp was the language you should be using? It's just an interesting point (what actually got me responding to the original post in the first place) and could be useful for me at some point in time...
But if the target of your rewrite rules in apache was /en/homepage vs /jp/homepage on somehost, there had to be some information which had dinstiguished the two requests which apache sees, because it redirected to different paths. The typical case would be that the domain was different, i.e. "somehost.co.uk" vs. "somehost.jp", so you can test for that in zope also. I can't imagine a case where the information, which led apache to make different rewriting decisions, isn't available in zope anymore. cheers, oliver
Dieter> When you do it right, there may be no need to know about the Dieter> "Zope" intermediate URL segment. Personally, I would go for such Dieter> a solution. Any clues? If I want to send back a redirect, how to I "do it right" so the browser at the other end gets a valid URL? Someone else mentioned SiteRoot but the docs made me suspect a simple mistake would break things badly. You mentioned VirtualHostMonster, but I can't find any docs about it at all. I tried creating one. When I select it, the Mapping tab says I don't need to use that tab if I run Apache in front of Zope (which is the case for this particular installation). The About tab mentions stuff like VirtualHostBase and VirtualHostRoot but gives no clues about where to set them. There are no other tabs and no help link. Searching the help stuff for VirtualHostMonster returns no matches. Where am I supposed to edit the dang thing? Apache proxies requests for http://www.thishost.com/Zope/... to Zope. So http://www.thishost.com/Zope/xyz refers to the xyz object in my SiteRoot. When I call xyz.absolute_url() or xyz.getPhysicalPath() from a Python script I want some indication that the URL contains "/Zope/..." as the path prefix. -- Skip Montanaro - skip@pobox.com http://www.mojam.com/ http://www.musi-cal.com/
Skip Montanaro wrote:
Dieter> When you do it right, there may be no need to know about the Dieter> "Zope" intermediate URL segment. Personally, I would go for such Dieter> a solution.
Any clues? If I want to send back a redirect, how to I "do it right" so the browser at the other end gets a valid URL?
Send a redirect to: object_where_you_want_to_redirect.absolute_url() Zope will do the right thing.
Someone else mentioned SiteRoot but the docs made me suspect a simple mistake would break things badly.
You mentioned VirtualHostMonster, but I can't find any docs about it at all.
See for instance http://www.zope.org/Members/Jace/apache-vhm There are other howtos on zope.org, they should all reside under "Administrator Howtos". HTH, oliver
participants (5)
-
Chris Beaven -
Dieter Maurer -
Oliver Bleutgen -
Skip Montanaro -
Tim Freund