> At this point I'm not concerned with directory containers, I'm just > trying to get virtual hosts to work the way I want with directives that > apply server-wide. The docs say: "If these functions are not supplied > the following default behavior takes place: the child container inherits > its parent configuration, unless it specifies its own and then it > overrides its parent configuration." > > As luck would have it, this is exactly the behavior I want, so I figure > I'm good to go. Unfortunately, this isn't what actually happens by > default. What actually happens is that the virtual host inherits the > main server's configuration, but if *any* directives from the module > are specified within the virtual host, *none* of them are inherited and > the entire configuration must be repeated in the virtual host.
your description sounds correct for default behavior. and I think it matches what you quoted :) > > So, following what I think the docs are saying (they are pretty > incomprehensible on this subject) I add a simple SERVER_MERGE function > that merges the two hashes to try to duplicate what I thought was the > default behavior. I observe no change, so I try increasingly crazy > things in this function, debug dumps, and ultimately deliberate fatal > run-time errors, and determine that this function is in fact never > getting called at all. you need to specify both SERVER_CREATE and SERVER_MERGE. I suspect that's your problem here. or, more likely, DIR_CREATE and DIR_MERGE - SERVER_CREATE and SERVER_MERGE are only for things that can exist only on a per-server level, such as the PerlTransHandler (as opposed to the PerlFixupHandler which can appear per-server or per-directory). make sense? > > So, either I'm retrieving the values incorrectly, or I'm misunderstanding > the default behavior. no, I think you have it right. basically, things merge on their own until _any_ custom directive appears in a container. at that point the container gets _only_ those custom directives explicitly defined in the container and nothing merges. if you want to override that behavior - say, use the one specified in the container _and_ those defined in a parent container or on a per-server level, then you need to implement DIR_CREATE and DIR_MERGE. > > my $cfg = Apache2::Module::get_config(__PACKAGE__,$r->server, > $r->per_dir_config); > > (It makes no difference whether the per_dir_config thing is in there, > which I don't think it should since I'm not even trying directory > containers at this point.) Using the above, the only way any of the > directives are inherited by the virtual host is if I specify none of > them within the virtual host section. If any directives from the > module are specified, those are the only ones that appear. > > And, I must be missing the part about how to get my SERVER_MERGE function > to be called. The examples in the docs do not work as-is. > > Any clues would be greatly appreciated. see http://people.apache.org/~geoff/Directive-2.tar.gz for a quick example. run 'make test' then look in the error_log - you'll see the initial request gets the uppermost config, but the second request gets a merged config, with one directive from the parent and one from the current container. well, in this case the "container" is an .htaccess file, but those are essentially the same for purposes of merging. anyway, HTH --Geoff