SiteAccess_vhosting
http://www.hotsite.com to publish the Zope object /hotsite/index_html.
Then http://www.hotsite.com is the URI of your logical root, and /hotsite is the
path to your physical root.
/hotsite, your site's physical root, and accept the
default Path. Create a DTML Method in the Zope root folder containing
Is the first-level domainUse "Set Access Rule" with the DTML Method's Id. Want to understand this? Read on.hotsite.com? Ignore sub-domains and port number. <dtml-if ".string.split(.string.split(HTTP_HOST,:)[0],.)[-2:]==[hotsite, 'com']"> Add physical root: <dtml-call "REQUEST['TraversalRequestNameStack'].append(hotsite)"> </dtml-if >
http://www.hotsite.com/(.*) to
/blah/cgi/Zope.cgi/hotsite/$1, for example.
hotsite object before any others in the URI.
<a href="<dtml-var URL>/hottopics">in object
/hotsite/forum will generate
<a href="http://www.hotsite.com/hotsite/forum/hottopics"> rather than <a href="http://www.hotsite.com/forum/hottopics">To prevent this, all of the URLn and BASEn? request variables and the absolute_url() method need to be told to strip off
/hotsite. That's what
SiteRoot objects do.
/hotsite, in
this case) and told the logical URL at which to base all requests passing
through this folder. You tell it by setting its Path property, which in this
case should have the value /.
SiteRootPATH of the /hotsite folder or of the root folder,
or it can be set in the rewriting Access Rule with a call to
"REQUEST.set(SiteRootPATH, /)", or it can be passed in from the
mediating web server as an environment variable. You can also provide
a Base (SiteRootBASE) value, which will then replace the host:port/script
portion of URIs?.
hotsite.net, fooflowers.com, and openmouths.org
from /hotsite, /foof, and /openm respectively. We are distinguishing
requests via HTTP_HOST, and we don't care what subdomain or port was specified.
/hotsite, /foof, and /openm.
In each one, erase the default Path and leave Base blank.
Make a DTML Method in the root folder containing
Extract the part of HTTPHOST we care about, and declare our rewrite dictionary. <dtml-let hostname=".string.join(.string.split(.string.split(HTTP_HOST,Use "Set Access Rule" with the DTML Method's Id. An almost identical method can be used to distinguish sites by SERVER_ADDRESS and SERVER_PORT instead of HTTP_HOST. In that case, though, you would probably add a line to set the appropriate SiteRootBASE?.:)[0],.)[-2:],.)" sitemap="{'hotsite.net':hotsite, 'fooflowers.com':foof, 'openmouths.org': 'openm'}"> Do we have a match? <dtml-if expr="sitemap.has_key(hostname)"> Set the logical root: <dtml-call "REQUEST.set(SiteRootPATH,/)"> Add physical root: <dtml-call "REQUEST['TraversalRequestNameStack'].append(sitemap[hostname])"> </dtml-if> </dtml-let>
vhosts, you could add the line:
Add vhost root: <dtml-call "REQUEST['TraversalRequestNameStack'].append(vhosts)">
after the Add physical root line. If you wanted to add multiple path
elements for each site, you could use path.extend instead of path.append and
map fooflowers.org, for example, to [foof, f, 'comsites']?. This would
place the root of fooflowers in folder /comsites/f/foof/.
ignored "> to exit the Rule.
It also means that if you want to redirect within an Access Rule, you must use
<dtml-raise type="Redirect"> instead of
"RESPONSE.redirect()"magic folder start all
management interactions. I use Z, and wrap the rest of the Access Rule
code in something like:
Is there a path, and does it start withZ? <dtml-let stack="REQUEST['TraversalRequestNameStack']"> <dtml-if "stack and stack[-1]==Z"> Get rid of 'Z': <dtml-call "stack.pop()"> Put it back logically: <dtml-call "REQUEST.setVirtualRoot(Z)"> <dtml-else> ... </dtml-if> </dtml-let>
Zope global-access prefix as described
above, then the else part should contain something like
<dtml-call "REQUEST.set(SiteRootPATH, /)">.
| Last edited Sun, 10 Sep 2006 00:59:10 +0900 | Edit this page |