/lurk :)

we're having trouble translating a standard httpd.conf setup into
a <Perl> section when there's a directive that can be legally
repeated multiple times, such as PerlSetVar --

objective: translate MULTIPLE "PerlSetVar" from straight
httpd.conf into <Perl>perl sections code</Perl>.

<VirtualHost *>
        ...
        PerlSetVar MasonCompRoot        /var/www/mywebsite
        PerlSetVar MasonDataDir         /var/cache/mason/mywebsite
        PerlSetVar MasonAutoHandlerName my.autohandler.mason
        PerlSetVar MasonDHandlerName    my.dhandler.mason
        PerlSetVar MasonDeclineDirs     0
        ...
</VirtualHost>

we figured we could translate that into <Perl> sections thus:

        push @{$VirtualHost{'*'}},{
                ...
                PerlSetVar => [
                        MasonCompRoot        => "/var/www/$site",
                        MasonDataDir         => "/var/cache/mason/$site",
                        MasonAutoHandlerName => "$autohandlername",
                        MasonDHandlerName    => "$dhandlername",
                        MasonDeclineDirs     => '0',
                ],
                ...
        };

but that gives the following error:

"Syntax error on line 3 of /etc/apache2/sites-enabled/perl:
PerlSetVar takes two arguments, PerlSetVar at
/usr/lib/perl5/Apache2/Apache/PerlSections.pm line 177."

we've also tried sub-arrays, thus:

                PerlSetVar => [
                        [ MasonCompRoot        => "/var/www/$site", ],
                        [ MasonDataDir         => "/var/cache/mason/$site", ],
                        [ MasonAutoHandlerName => "$autohandlername", ],
                        [ MasonDHandlerName    => "$dhandlername", ],
                        [ MasonDeclineDirs     => '0', ],
                ],

with identical (failed) results.

after revisiting the docs for the eleventh time, i see that they
(both for mp1 and mp2, at perl.apache.org) mention:

        <quote>
        If an Apache directive can take two or three arguments you may
        push strings (the lowest number of arguments will be shifted off
        the @list) or use an array reference to handle any number
        greater than the minimum for that directive:

                push @Redirect, "/foo", "http://www.foo.com/";;
                push @Redirect, "/imdb", "http://www.imdb.com/";;
                push @Redirect, [qw(temp "/here" "http://www.there.com";)];
        </quote>

i presume these three lines of code are all intended to be taken
as one block from an example script; if so, the resulting
@Redirect will look like this:

        @Redirect = (
                '/foo',
                'http://www.foo.com/',
                '/imdb',
                'http://www.imdb.com/',
                [
                        'temp',
                        '/here',
                        'http://www.there.com',
                ],
        );

but perusing Apache2/Apache/PerlSections.pm it looks like sub
dump_entry should generate this (wrong config) instead of what's
expected:

        Redirect /foo
        Redirect http://www.foo.com/
        Redirect /imdb
        Redirect http://www.imdb.com/
        Redirect temp /here http://www.there.com

except (as the docs mention) there's probably some per-directive
facility to override the defaults, where it shifts the right number
of items off the list.

but i digress.

so as a workaround, in theory, we could do this:

                PerlSetVar => [
                        ["MasonCompRoot        /var/www/$site",],
                        ["MasonDataDir         /var/cache/mason/$site",],
                        ["MasonAutoHandlerName $autohandlername",],
                        ["MasonDHandlerName    $dhandlername",],
                        ["MasonDeclineDirs     0",],
                ],

now this should get dumped into the config (via lines 153-5 of
Apache2/Apache/PerlSections, v0.01:

        elsif ($type eq 'ARRAY') {
                $self->add_config("$name @$entry\n");
        }

) to be exactly what we started with in the pre-perl config
above, right?

zut alors.

even with this approach, we STILL get the "PerlSetVar takes two
arguments"...  business.

what's the workaround? didn't see anything like this in our
searchings through the mod_perl list archives...

we also tried "grep -ri 'takes two arguments'
/usr/lib/perl5/Apache2" and turned up nothing. where's the error
message actually coming from?

any pointers greatefully welcomed!

===

# apache2 -v
Server version: Apache/2.0.48
Server built:   Jan 30 2004 20:35:32
# uname -a
Linux tigris 2.4.21-xfs #13 SMP Tue Aug 26 01:46:14 CEST 2003 i686 GNU/Linux

using debian sarge (still in state "testing" at the moment, but
closing in on "stable" real soon now)

-- 
will trillich
http://www.serensoft.com/
http://www.midwestRepo.com/
http://www.skylineAuto.net/


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html

Reply via email to