Re: [MP2] Accessing custom config directives from an PostConfig handler

[prev] [thread] [next] [Date index for 2005/05/23]

From: Torsten Foertsch
Subject: Re: [MP2] Accessing custom config directives from an PostConfig handler
Date: 20:19 on 23 May 2005
--nextPart22801543.1d4aX0a0AT
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

On Monday 23 May 2005 19:54, Stas Bekman wrote:
> Geoffrey Young wrote:
> > Torsten Foertsch wrote:
> >>Hi,
> >>
> >>I have created my own configuration directives with Apache2::Module::ad=
d.
> >> How can I access the values from an PostConfig handler?
> >>
> >>I have got it working with the main server. But if my directives are
> >> inside a VirtualHost they are not accessible.
> >>
> >>
> >>Apache2::ServerUtil->server
> >
> > IIRC the issue is that in post-config you aren't actually attached to a
> > server, so you need to iterate the list of servers and find the one (by
> > name I guess) that you are intersted in.  IIRC there were some examples
> > in the archives of how to do this.  at the very least you can check out
> > mod_rewrite, which I belive does exactly that (in C though :)
>
> It's documented:
> http://perl.apache.org/docs/2.0/api/Apache2/ServerRec.html#C_next_
> http://perl.apache.org/docs/2.0/user/handlers/server.html#C_PerlOpenLogsH=
an
>dler_
>
> Torsten, if you think we could add a xref to this technique elsewhere that
> it'd make it easier to find it, please suggest. I agree that it's not easy
> to do now, unless you know things well.
>
> e.g. may be a xref from:
> http://perl.apache.org/docs/2.0/user/handlers/server.html#C_PerlPostConfi=
gH
>andler_ to:
> http://perl.apache.org/docs/2.0/user/handlers/server.html#C_PerlOpenLogsH=
an
>dler_ will help? e.g.:
>
> If you want to traverse the configured virtual hosts, you can accomplish
> that using a simple loop (see PerlOpenLogsHandler for an example)


I already had had a loop

for( my $srv=3DApache2::ServerUtil->server; $srv; $srv=3D$srv->next ) {...}

But in the same function I had a variable named $s that also was a server=20
object. Now due to a simple spelling mistake inside the loop I had looked 5=
=20
times at $s instead of $srv wondering why my configuration was undef all th=
e=20
time, ;-).

I think a document explaining the fundamental Apache/mod_perl data structur=
es=20
in terms of C _and_ mod_perl would be good. Then it can be linked from the=
=20
rest of the docs. BTW, is there somewhere a good Apache API documentation?=
=20
All my knowledge about it comes from looking at mod_perl, mod_dir,=20
mod_rewrite, mod_ssl, etc.

Torsten

--nextPart22801543.1d4aX0a0AT
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQBCkjq7wicyCTir8T4RAqUaAKCaV9qnYP988v8K2/pWQs9un0w7DgCfU7FR
CXaRQnYXn7PxUhsoBzWUtp8=
=qVoY
-----END PGP SIGNATURE-----

--nextPart22801543.1d4aX0a0AT--

Re: [MP2] Accessing custom config directives from an PostConfig handler
Torsten Foertsch 20:19 on 23 May 2005

Generated at 20:12 on 05 Jun 2005 by mariachi v0.52