I'm very late in replying, but this is exactly the problem I am having.

I understand the idea behind NOT running multiple paths unless one of them is a shared file directory.

Unfortunately this is largely a "play" server right now. Call it development, where I'm not really in a position to set up multiple virtual hosts for each scenario of testing stuff.

I suppose one option is to use unique filenames...
And another one would be to augment the <Location>...

Thanks.

Jason Kohles wrote:
On 11/18/05, *Tom Allison* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    I'm a bit confused as some behavior I'm getting regading DocumentRoot
    settings.

    I have three directories in question:
    the apache root (/var/www)
    my personal space (~/public/html)
    and a mason directory in my personal space.

    PerlAddVar      MasonCompRoot   "main=> /var/www"
    PerlAddVar      MasonCompRoot   "tom => /home/tallison/public_html"

    When both of these are enabled, and I access ~/tallison/ I get the home
    page /index.html instead of my personal homepage ~/tallison/index.html
    despite the fact that the URL says I'm at ~/tallison/index.html.
    There are no mason files in either of these directories, just one
    index.html each.


comp_root is a search path, by including both of them in your handler, you are telling HTML::Mason to search those directories for components. What happens when you point a browser at http://.../~tallison/ is this (some of this is assumption, since you don't indicate how Mason is setup other than the comp_root entries):

* Your browser connects to the web server and requests /~tallison/
* Apache sees that it is a directory, and decides that the real request should be /~tallison/index.html * Since you have (I assume) a Location entry indicating that Mason should handle *.html files under /~tallison/, Apache dispatches the request to your ApacheHandler, indicating that the filename is index.html * HTML::Mason looks at your configuration and sees that you have more than one component root, so it looks through them (in the order you specified) to find a file matching the request. It finds /var/www/html/index.html and serves that, since it found a matching file, it doesn't need to continue down the search path to find the other index.html file.

    If I remove the 'main' line, everything works just fine.

    I just don't understand why.  I see no reason why mason would do
    anything in the directory ~/tallison/ when there is only a very simple
    index.html page (as in <p>hello world</p> as a placemarker).

Normally you wouldn't use multiple comp_roots the way you have here, the reason to specify multiples is if you want to share some components between sites. For example, I have some mason components that I use on all my sites, but they each have their own html pages. So I setup my filesystem something like this:

/var/www/site1 DocumentRoot for www.site1.com <http://www.site1.com>
/var/www/site1/index.html   Main Index for site1
/var/www/site2 DocumentRoot for www.site2.com <http://www.site2.com>
/var/www/site2/index.html   Main Index for site2
/var/www/site3 DocumentRoot for www.site3.com <http://www.site3.com>
/var/www/site3/index.html   Main Index for site3

Then I created a directory for the components that each site will share (in my case, I usually use /var/www/shared) and I put in that directory, some common components:

/var/www/shared/...
    menu.mas                     Mason menu component
table.mas Mason component for easily building tables of data ajax.mas Mason component that generates AJAX JavaScript
    forms.mas                     Mason component for generating forms

Then in my Apache configuration, I will create a separate ApacheHandler for each site (there is information on how to do this in the HTML::Mason::Admin documentation). The important part of the configuration is that each site has two comp_root entries, one for it's own DocumentRoot, and one for the shared (the shared one comes last, so that any of the common components can be overridden per-site):

<VirtualHost www.site1.com <http://www.site1.com>>
...
PerlAddVar MasonCompRoot "site1 => /var/www/site1"
PerlAddVar MasonCompRoot "shared => /var/www/shared"
...
</VirtualHost>
<VirtualHost www.site2.com <http://www.site2.com>>
...
PerlAddVar MasonCompRoot "site2 => /var/www/site2"
PerlAddVar MasonCompRoot "shared => /var/www/shared"
...
</VirtualHost>
<VirtualHost www.site3.com <http://www.site3.com>>
...
PerlAddVar MasonCompRoot "site3 => /var/www/site3"
PerlAddVar MasonCompRoot "shared => /var/www/shared"
...
</VirtualHost>

Now, any of the three sites can include <& 'menu.mas' &> to call the component that generates a menu, and it will work, even though there is only one copy of the menu.mas file (in /var/www/shared). If I make changes to the components in /var/www/shared, those changes affect all three sites, if I want to make changes that don't affect all three, then I can copy the component into /var/www/site1 for example, and now site1 will have it's own copy that I can modify without affecting the other two sites.

--
Jason Kohles
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> - http://www.jasonkohles.com/
"A witty saying proves nothing."  -- Voltaire



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to