Apache-HeavyCGI
view release on metacpan or search on metacpan
lib/Apache/HeavyCGI.pm view on Meta::CPAN
$val = $req->param($name);
}
defined $val or
defined($val = $arg{value}) or
defined($val = $arg{default}) or
($val = "");
sprintf qq{<input type="$fieldtype"
name="%s" value="%s"%s%s />},
$self->escapeHTML($name),
$self->escapeHTML($val),
exists $arg{size} ? " size=\"$arg{size}\"" : "",
exists $arg{maxlength} ? " maxlength=\"$arg{maxlength}\"" : "";
}
sub uri_escape {
my Apache::HeavyCGI $self = shift;
my $string = shift;
return "" unless defined $string;
require URI::Escape;
my $s = URI::Escape::uri_escape($string, '^\w ');
$s =~ s/ /+/g;
$s;
}
sub uri_escape_light {
my Apache::HeavyCGI $self = shift;
require URI::Escape;
URI::Escape::uri_escape(shift,q{<>#%"; \/\?:&=+,\$}); #"
}
1;
=head1 NAME
Apache::HeavyCGI - Framework to run complex CGI tasks on an Apache server
=head1 SYNOPSIS
use Apache::HeavyCGI;
=head1 WARNING UNSUPPORTED ALPHA CODE RELEASED FOR DEMO ONLY
The release of this software was only for evaluation purposes to
people who are actively writing code that deals with Web Application
Frameworks. This package is probably just another Web Application
Framework and may be worth using or may not be worth using. As of this
writing (July 1999) it is by no means clear if this software will be
developed further in the future. The author has written it over many
years and is deploying it in several places. B<Update 2006-02-03:
Development stalled since 2001 and now discontinued.>
There is no official support for this software. If you find it useful
or even if you find it useless, please mail the author directly.
But please make sure you remember: THE RELEASE IS FOR DEMONSTRATION
PURPOSES ONLY.
=head1 DESCRIPTION
The Apache::HeavyCGI framework is intended to provide a couple of
simple tricks that make it easier to write complex CGI solutions. It
has been developed on a site that runs all requests through a single
mod_perl handler that in turn uses CGI.pm or Apache::Request as the
query interface. So Apache::HeavyCGI is -- as the name implies -- not
merely for multi-page CGI scripts (for which there are other
solutions), but it is for the integration of many different pages into
a single solution. The many different pages can then conveniently
share common tasks.
The approach taken by Apache::HeavyCGI is a components-driven one with
all components being pure perl. So if you're not looking for yet
another embedded perl solution, and aren't intimidated by perl, please
read on.
=head2 Stacked handlers suck
If you have had a look at stacked handlers, you might have noticed
that the model for stacking handlers often is too primitive. The model
supposes that the final form of a document can be found by running
several passes over a single entity, each pass refining the entity,
manipulating some headers, maybe even passing some notes to the next
handler, and in the most advanced form passing pnotes between
handlers. A lot of Web pages may fit into that model, even complex
ones, but it doesn't scale well for pages that result out of a
structure that's more complicated than adjacent items. The more
complexity you add to a page, the more overhead is generated by the
model, because for every handler you push onto the stack, the whole
document has to be parsed and recomposed again and headers have to be
re-examined and possibly changed.
=head2 Why not subclass Apache
Inheritance provokes namespace conflicts. Besides this, I see little
reason why one should favor inheritance over a B<using> relationship.
The current implementation of Apache::HeavyCGI is very closely coupled
with the Apache class anyway, so we could do inheritance too. No big
deal I suppose. The downside of the current way of doing it is that we
have to write
my $r = $obj->{R};
very often, but that's about it. The upside is, that we know which
manpage to read for the different methods provided by C<$obj->{R}>,
C<$obj->{CGI}>, and C<$obj> itself.
=head2 Composing applications
Apache::HeavyCGI takes an approach that is more ambitious for handling
complex tasks. The underlying model for the production of a document
is that of a puzzle. An HTML (or XML or SGML or whatever) page is
regarded as a sequence of static and dynamic parts, each of which has
some influence on the final output. Typically, in today's Webpages,
the dynamic parts are filled into table cells, i.e. contents between
some C<< <TD></TD> >> tokens. But this is not necessarily so. The
static parts in between typically are some HTML markup, but this also
isn't forced by the model. The model simply expects a sequence of
static and dynamic parts. Static and dynamic parts can appear in
random order. In the extreme case of a picture you would only have one
part, either static or dynamic. HeavyCGI could handle this, but I
don't see a particular advantage of HeavyCGI over a simple single
( run in 2.398 seconds using v1.01-cache-2.11-cpan-df04353d9ac )