* Yann Kerherv <[EMAIL PROTECTED]> [2002-07-30 09:30]:
> Quick and dirty hack around Apache::Request, to turn it into a
> plugin :
> 

[-- snip --]

> It works, but I guess it's quite dirty... any suggestion is welcome :)

I wrote a similar plugin a little while ago, which you can find at
<http://apache-tt2.sourceforge.net/Template-Plugin-Apache-1.01.tar.gz>,
and attached.  All things considered, though, it's not that different
from yours.   I've added the unescape_uri and unescape_uri_info methods,
and some documentation.

Here is the POD:

NAME
    Template::Plugin::Apache -

DESCRIPTION
    This is a very simple Template Toolkit Plugin interface to the
    Apache module. An Apache object will be instantiated via the following
    directive:

        [% USE Apache %]

    Apache methods may then be called as follows:

        [% Apache.header_in("Content-type") %]
        [% Apache.get_remote_host %]

    An alias can be used to provide an alternate name by which the
    object should be identified.

        [% USE r = Apache %]
        [% headers = r.headers_in %]

    All the usual Apache methods are available, including the
    Apache::Connection and Apache::Server objects, dir_configs, headers
    (incoming and outgoing), notes and pnotes, and so on.

        [% c = r.connection %]
        [% s = r.server %]

        Hello, [% c.remote_addr %]!
        How is [% r.header_in("User-agent") %] treating you?

        [% smtp_server = r.dir_config("SMTPServer") %]

        [% random_data = Apache.pnotes("random-data") %]

    Logging is availabe via the Apache::Log class, Apache.log:

        [% r.log.warn("H0ly 5h1t w00t!!!~!~!~~~") %]

    The plugin also exposes Apache's implementation of unescape_url()
    and unescape_url_info() (for escaping URLs and paths, and form
    parameters, respectively; see the Apache manpage):

        [% unescaped = Apache.unescape_url(escaped);
           unescape_info = Apache.unescape_url_info(escaped) %]

It still needs some work; there is no documentation for the param
function, for example.  But it works, and is mostly complete.

(darren)

-- 
Maybe that's the only truth in the world.
Not the Bibles or poetry or philosophy but just the old jokes.
    -- Robert Shea and Robert Anton Wilson

Attachment: Template-Plugin-Apache-1.01.tar.gz
Description: application/tar-gz

Reply via email to