You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Dave Rolsky <au...@urth.org> on 2002/05/19 02:53:14 UTC

And some strangeness with dir_config

ok, I just discovered this

PerlOptions +GlobalRequest

which fixes my previous problem, though it seems that maybe the default
should be for this to be on, at least when Apache::compat is loaded, and
maybe all the time since CGI.pm needs it.

Now my new problem is that given this config:

  PerlSetVar MasonArgsMethod CGI

  PerlSetVar MasonAllowGlobals $Schema
  PerlAddVar MasonAllowGlobals $UserSession
  PerlAddVar MasonAllowGlobals $AdminSession

  PerlModule HTML::Mason::ApacheHandler

  <Directory /var/www>
    <FilesMatch "\.mhtml$">
     SetHandler perl-script
     PerlResponseHandler HTML::Mason::ApacheHandler
    </FilesMatch>
  </Directory>
</IfModule>


For some reason, Apache->request->dir_config returns an empty table (no
keys or values) even though Apache->server->dir_config has the revelant
config info.


-dave

/*==================
www.urth.org
we await the New Sun
==================*/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: And some strangeness with dir_config

Posted by Stas Bekman <st...@stason.org>.
Doug MacEachern wrote:

>>For some reason, Apache->request->dir_config returns an empty table (no
>>keys or values) even though Apache->server->dir_config has the revelant
>>config info.
> 
> 
> i can see why this is happening, the per-server and per-dir tables are not 
> merged.  one thing that'll work in the meantime is $r->dir_config($key), 
> which looks in the per-server table if the per-directory entry does not 
> exist.

How come the modperl/dir_config.t test wasn't catching that? I thought 
we didn't have this test, but then I've found it.

Or do we still miss some test, please tell me which.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: And some strangeness with dir_config

Posted by Dave Rolsky <au...@urth.org>.
On Sat, 18 May 2002, Doug MacEachern wrote:

> Apache->request is deprecated.  its error-prone and hurts performance when
> using threaded MPMs, since it has to use thread local storage.
> CGI.pm can be changed not to use it.  why does mason use it when your
> handler is passed $r ?

Because we have some code that can be called either after the handler is
invoked _or_ when the server is loaded.  So we do:

  my $config = Apache->request ? Apache->request->dir_config : Apache->server->dir_config;

I can probably arrange to have $r make its way to that sub though.

> i can see why this is happening, the per-server and per-dir tables are not
> merged.  one thing that'll work in the meantime is $r->dir_config($key),
> which looks in the per-server table if the per-directory entry does not
> exist.

I could do that.  Right now we get all the entries first and then figure
out which ones belong to Mason, but that's probably not the best way to
handle it anyway.


-dave

/*==================
www.urth.org
we await the New Sun
==================*/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: And some strangeness with dir_config

Posted by Doug MacEachern <do...@covalent.net>.
On Sat, 18 May 2002, Dave Rolsky wrote:

> ok, I just discovered this
> 
> PerlOptions +GlobalRequest
> 
> which fixes my previous problem, though it seems that maybe the default
> should be for this to be on, at least when Apache::compat is loaded, and
> maybe all the time since CGI.pm needs it.

Apache->request is deprecated.  its error-prone and hurts performance when 
using threaded MPMs, since it has to use thread local storage.
CGI.pm can be changed not to use it.  why does mason use it when your 
handler is passed $r ?
 
> For some reason, Apache->request->dir_config returns an empty table (no
> keys or values) even though Apache->server->dir_config has the revelant
> config info.

i can see why this is happening, the per-server and per-dir tables are not 
merged.  one thing that'll work in the meantime is $r->dir_config($key), 
which looks in the per-server table if the per-directory entry does not 
exist.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: And some strangeness with dir_config

Posted by Doug MacEachern <do...@covalent.net>.
On Sat, 18 May 2002, Dave Rolsky wrote:
 
> For some reason, Apache->request->dir_config returns an empty table (no
> keys or values) even though Apache->server->dir_config has the revelant
> config info.

the port from the 1.x Perl{Set,Add}Var directive handler code missed a bit 
of logic, fixed now in cvs.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: And some strangeness with dir_config

Posted by Doug MacEachern <do...@covalent.net>.
On Sat, 18 May 2002, Dave Rolsky wrote:
 
> More follow up.
> 
> When $c is an APR::Table object, this code:
> 
> 	while (my ($k, $v) = each %$c)
> 	{
> 	    warn " $k => $v\n";
> 	}
> 
> prints
> 
>  MasonAllowGlobals => $Schema
> 
> 3 times over, instead of print $Schema, $UserSession, & $AdminSession.

i think 1.x has the same issue with multi-value keys.  the perl tied hash 
interface uses FIRSTKEY/NEXTKEY where we are able to maintain some state, 
but once the key is returned, perl calls FETCH with that key, 
apr_table_get will always return the first value.

better off using $c->do().


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: And some strangeness with dir_config

Posted by Dave Rolsky <au...@urth.org>.
On Sat, 18 May 2002, Dave Rolsky wrote:

> On Sat, 18 May 2002, Dave Rolsky wrote:
>
> > Now my new problem is that given this config:
> >
> >   PerlSetVar MasonArgsMethod CGI
> >
> >   PerlSetVar MasonAllowGlobals $Schema
> >   PerlAddVar MasonAllowGlobals $UserSession
> >   PerlAddVar MasonAllowGlobals $AdminSession
> >
> >   PerlModule HTML::Mason::ApacheHandler
> >
> >   <Directory /var/www>
> >     <FilesMatch "\.mhtml$">
> >      SetHandler perl-script
> >      PerlResponseHandler HTML::Mason::ApacheHandler
> >     </FilesMatch>
> >   </Directory>
> > </IfModule>

More follow up.

When $c is an APR::Table object, this code:

	while (my ($k, $v) = each %$c)
	{
	    warn " $k => $v\n";
	}

prints

 MasonAllowGlobals => $Schema

3 times over, instead of print $Schema, $UserSession, & $AdminSession.


-dave

/*==================
www.urth.org
we await the New Sun
==================*/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: And some strangeness with dir_config

Posted by Dave Rolsky <au...@urth.org>.
On Sat, 18 May 2002, Dave Rolsky wrote:

> Now my new problem is that given this config:
>
>   PerlSetVar MasonArgsMethod CGI
>
>   PerlSetVar MasonAllowGlobals $Schema
>   PerlAddVar MasonAllowGlobals $UserSession
>   PerlAddVar MasonAllowGlobals $AdminSession
>
>   PerlModule HTML::Mason::ApacheHandler
>
>   <Directory /var/www>
>     <FilesMatch "\.mhtml$">
>      SetHandler perl-script
>      PerlResponseHandler HTML::Mason::ApacheHandler
>     </FilesMatch>
>   </Directory>
> </IfModule>

As a follow up.  If I add this:

  PerlSetVar  FOO BAR

_inside_ the FilesMatch section, then that is available from
Apache->request->dir_config, but only that key.  Conversely, that key is
_not_ available from Apache->server.


The latter makes sense but the former seems somewhat broken.


-dave

/*==================
www.urth.org
we await the New Sun
==================*/


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org