You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Robin Berjon <ro...@knowscape.com> on 2000/12/09 01:53:00 UTC

custom directives done using filters

Hi,

I feel bad insisting because I know most of you are probably at least as
busy as I am. I posted a message a few days ago
(http://www.geocrawler.com/lists/3/Web/182/200/4787953/) and didn't get a
single answer. I understand if you don't want to read it as it's fairly
long. Basically, I'm trying to some up with a way to implement custom
directives by applying Perl source filters in httpd.conf, but for some
reason it isn't working.

If any of you know anything that could help me find a way to make it work
(or give me a definitive answer that it simply can't be done) it'd be very
much appreciated.

Thanks,

-- robin b.
Heisenberg might have been here.


Re: custom directives done using filters

Posted by Robin Berjon <ro...@knowscape.com>.
At 18:27 10/12/2000 +0100, Stas Bekman wrote:
>Check this out:
>http://perl.apache.org/guide/config.html#Apache_Configuration_in_Perl
>at the end of the section...

Stas there's just way too much good information in the guide ;) mount -t
html http://perl.apache.org/guide /brain/docs/guide would sure be a nice
thing to see possible.

>You don't need perl sections to configure Apache in Perl, just declare the
>Apache::ReadConfig package and do what you want... in Perl of
>course... and call it from startup.pl or else... before the server is
>started.

That a really nice thing to know and chances are I'll use it for some
things. But the rub is I don't want to configure my Apache in Perl. Perl is
great for many things but apart from the cases where one can benefit from
dynamic configuration (eg pulling conf info from a database, using the same
conf for several servers that want different settings, defining many vhosts
in a loop, etc...) I don't think it's a big win over using a syntax that
was tailored for configuration. The latter is much more legible.

Right now the situation is that when one wants to add a new type of
directive that Apache understands, one has to write a custom Makefile.PL
that will take care of generating some XS that will know how to talk to
Apache and to take the right steps required by the directive when it
appears. That's not quite as easy as doing pure Perl, requires some
compilation and occasionally cause mysterious problems with other modules
(eg AxKit and PHP for instance).

What I'd like to do is to provide the same functionality (ie the ability to
add new directives) but in a pure Perl fashion that wouldn't need to
interact with Apache at all, using Perl's Filter framework. Using that, one
would be able to provide directives that have the same kind of syntax as
the normal Apache directives. Of course, because this is Perl, one could
also invent all sorts of strange new directives using any kind of syntax
that Perl can parse.

Unfortunately, this doesn't appear to be possible directly within
httpd.conf :( The closest I got to making it work is by having an
httpd.conf containing solely:

<Perl>
require "conf/filtered_conf.conf";
</Perl>

and then have filtered_conf.conf contain my regular Apache conf, in
addition to use Apache::FilterConf; at the top and any custom directives
that I might want to have. But easy as it is to simply change one's
configuration to fit that scheme, it isn't as straightforward as having to
simply activate the filter on your conf and be done.

Anyway, thanks for the input :) If I come up with a viable solution, I'll
post it to the list.

-- robin b.
Radioactive cats have 18 half-lives.


Re: custom directives done using filters

Posted by Stas Bekman <st...@stason.org>.
On Sun, 10 Dec 2000, Robin Berjon wrote:

> At 23:28 08/12/2000 -0500, Jim Winstead wrote:
> >On Dec 09, Robin Berjon wrote:
> >> I feel bad insisting because I know most of you are probably at least as
> >> busy as I am. I posted a message a few days ago
> >> (http://www.geocrawler.com/lists/3/Web/182/200/4787953/) and didn't get a
> >> single answer. I understand if you don't want to read it as it's fairly
> >> long. Basically, I'm trying to some up with a way to implement custom
> >> directives by applying Perl source filters in httpd.conf, but for some
> >> reason it isn't working.
> >
> >the configuration file is actually read and processed by apache,
> >so i don't see how perl source filters could be applied to it.
> 
> I thought as much, but I was hoping that there'd be a way to trick into
> feeding it through Perl, probably using the Perl sections. But I guess it
> intervenes too early in the process. However it's a pity that there is no
> way to use a perl filter at least within <Perl>. I wouldn't mind putting my
> entire httpd.conf within a <Perl> section provided that I could use a
> filter, and thus keep the Apache config syntax + custom directives done
> this way. I guess that Perl sections are eval()ed, and unfortunately eval
> doesn't work with filters.

Check this out:
http://perl.apache.org/guide/config.html#Apache_Configuration_in_Perl
at the end of the section...

You don't need perl sections to configure Apache in Perl, just declare the
Apache::ReadConfig package and do what you want... in Perl of
course... and call it from startup.pl or else... before the server is
started.

When you have some nice example working, make sure to shoot it my way to
be included in the guide :)

_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide 
mailto:stas@stason.org   http://apachetoday.com http://logilune.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/  



Re: custom directives done using filters

Posted by Robin Berjon <ro...@knowscape.com>.
At 23:28 08/12/2000 -0500, Jim Winstead wrote:
>On Dec 09, Robin Berjon wrote:
>> I feel bad insisting because I know most of you are probably at least as
>> busy as I am. I posted a message a few days ago
>> (http://www.geocrawler.com/lists/3/Web/182/200/4787953/) and didn't get a
>> single answer. I understand if you don't want to read it as it's fairly
>> long. Basically, I'm trying to some up with a way to implement custom
>> directives by applying Perl source filters in httpd.conf, but for some
>> reason it isn't working.
>
>the configuration file is actually read and processed by apache,
>so i don't see how perl source filters could be applied to it.

I thought as much, but I was hoping that there'd be a way to trick into
feeding it through Perl, probably using the Perl sections. But I guess it
intervenes too early in the process. However it's a pity that there is no
way to use a perl filter at least within <Perl>. I wouldn't mind putting my
entire httpd.conf within a <Perl> section provided that I could use a
filter, and thus keep the Apache config syntax + custom directives done
this way. I guess that Perl sections are eval()ed, and unfortunately eval
doesn't work with filters.

-- robin b.
There's too much blood in my caffeine system. 


Re: custom directives done using filters

Posted by Jim Winstead <ji...@trainedmonkey.com>.
On Dec 09, Robin Berjon wrote:
> I feel bad insisting because I know most of you are probably at least as
> busy as I am. I posted a message a few days ago
> (http://www.geocrawler.com/lists/3/Web/182/200/4787953/) and didn't get a
> single answer. I understand if you don't want to read it as it's fairly
> long. Basically, I'm trying to some up with a way to implement custom
> directives by applying Perl source filters in httpd.conf, but for some
> reason it isn't working.

the configuration file is actually read and processed by apache,
so i don't see how perl source filters could be applied to it.

jim

Re: custom directives done using filters

Posted by Robin Berjon <ro...@knowscape.com>.
At 09:36 09/12/2000 +0000, Matt Sergeant wrote:
>On Sat, 9 Dec 2000, Robin Berjon wrote:
>> Basically, I'm trying to some up with a way to implement custom
>> directives by applying Perl source filters in httpd.conf, but for some
>> reason it isn't working.
>
>It slipped past me on a busy day, but looks like it could work well to
>solve the segfaulting AxKit+PHP problems...

Yes that's one thing I had in mind when I started playing around with this
idea. Using a filter wouldn't allow one to do more than what is already
possible either with XS, PerlSetVar or of course <Perl>, but it would be
imho easier (both for the author and for the users that always seem to run
into problems) than XS, more powerful than PerlSetVar and would allow one
to stick to a configuration syntax more readable than Perl (which wasn't
meant to be used that way and doesn't look as obvious). Of course, some
twisted mind could always show up and implement Apache configuration in
Latin, but that's another story ;)

>I'm wondering if its something simple like the filter needs to read the
>file based on caller() in order to run the filter? I'd have to check the
>source for Filter to be certain though.

I think it's probably that <Perl> sections are eval()ed so that the filter
does not apply. That seems obvious from the fact that the filter() sub
never gets called at all, even though the filter itself is loaded,
initialised and added. Unfortunately I don't know enough about
Perl/mod_perl internals to think about a way to change this.

-- robin b.
There's too much blood in my caffeine system. 


Re: custom directives done using filters

Posted by Matt Sergeant <ma...@sergeant.org>.
On Sat, 9 Dec 2000, Robin Berjon wrote:

> Hi,
>
> I feel bad insisting because I know most of you are probably at least as
> busy as I am. I posted a message a few days ago
> (http://www.geocrawler.com/lists/3/Web/182/200/4787953/) and didn't get a
> single answer. I understand if you don't want to read it as it's fairly
> long. Basically, I'm trying to some up with a way to implement custom
> directives by applying Perl source filters in httpd.conf, but for some
> reason it isn't working.
>
> If any of you know anything that could help me find a way to make it work
> (or give me a definitive answer that it simply can't be done) it'd be very
> much appreciated.

It slipped past me on a busy day, but looks like it could work well to
solve the segfaulting AxKit+PHP problems...

I'm wondering if its something simple like the filter needs to read the
file based on caller() in order to run the filter? I'd have to check the
source for Filter to be certain though.

-- 
<Matt/>

    /||    ** Director and CTO **
   //||    **  AxKit.com Ltd   **  ** XML Application Serving **
  // ||    ** http://axkit.org **  ** XSLT, XPathScript, XSP  **
 // \\| // **     Personal Web Site: http://sergeant.org/     **
     \\//
     //\\
    //  \\