Seldo wrote:
Hello everyone -

I'm in the unfortunate position of being needing to write an Apache
2.0 module using mod_perl 2.0, while being simultaneously new to both
mod_perl, the Apache API, and perl itself. I guess I'm a glutton for
punishment, or something. (Did I mention this is all on Win32?)
You forgot to add to unfortunate facts that both mod_perl 2.0 and Apache 2.0 are new and may have bugs ;) But on the other hand you are the fortunate one to be one of the first to embrace the new platform. What doesn't kill you makes you stronger ;)

What I want my module to be able to do is to substitute content from
various plug-in applications as the response to various URLs. For
example, if the user requests
        www.mydomain.com/app1/file
I want app1.exe (or whatever) to retrieve a file / run a database
query / do some processing and return some output.
Do you say that the actual code resides in the database? So you want to fool Apache as if the code existed on the filesystem? Or does your database returns paths to the real files?

Importantly, I
*then* want the rest of Apache to treat this file as if it had come
from the file system, e.g. it it's a .php file I still want PHP to
handle it, if there are any other handlers assigned I still want them
to handle it. In short, this substitution has to be completely
transparent. (This should be possible by returning Apache::DECLINED,
but it doesn't seem to work like that, see below)

Now, I know it's possible to configure Apache with app1.exe as a
handler for /app1, etc.. What I'm creating is a single module that
handles *all* URLs (i.e. handles "/"), and manages the mapping itself.

So far, I think the best way to do this is to create a URI translation
handler module which will simply use $r->uri() to call the application
with whatever data and parameters it needs.
You mean PerlTransHandler, right? You are on the right track then.

First question:

1. Is this really the best way to supply the server with content that
comes from elsewhere than simply the file system?

I've written a simple translator which can return .html files, but if
I set the uri to a .php file the server seems to go into a loop (I've
been unable to diagnose what's actually happening).

2. Why would setting $r->uri() to a .php file be any different to the
rest of the server than setting it to a .html file?

and finally
If you don't have a real file with the content you probably need to rely on output filters.

3. How to ensure that the server treats the output of an application
the same as it does a file, i.e. applying all the necessary handlers
etc?
Assuming that you have a set of filters which do the work, it's easy. e.g. I think php in 2.0 is an output filter, so you should just dynamically insert the php filter when you figure out that the content is php. HTML/text is easy. SSI is a filter, so covered too. What other processors do you need?

Any and all advice appreciated, including "You fool! This already
exists!" :-)


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

Reply via email to