This is a handler for Maypole which will use the CGI instead of Apache's
C<mod_perl> 1.x. This handler can also be used for Apache 2.0.
+=head1 METHODS
+
+=over
+
+=item run
+
+Call this from your CGI script to start the Maypole application.
+
+=back
+
+=head1 Implementation
+
+This class overrides a set of methods in the base Maypole class to provide it's
+functionality. See L<Maypole> for these:
+
+=over
+
+=item get_request
+
+=item get_template_root
+
+=item parse_args
+
+=item parse_location
+
+=item send_output
+
+=back
+
=head1 AUTHORS
Dave Ranney C<dave@sialia.com>
Maypole
backend. Otherwise, see L<Maypole::Config/"template_root">
+=head3 get_request
+
+You should only need to define this method if you are writing a new
+Maypole backend. It should return something that looks like an Apache
+or CGI request object, it defaults to blank.
+
+
=head3 is_applicable
Returns a Maypole::Constant to indicate whether the request is valid.
Sends the output and additional headers to the user.
+=head3 call_authenticate
+
+This method first checks if the relevant model class
+can authenticate the user, or falls back to the default
+authenticate method of your Maypole application.
+
+
+=head3 call_exception
+
+This model is called to catch exceptions, first after authenticate
+,then after processing the model class, and finally to check for
+exceptions from the view class.
+
+This method first checks if the relevant model class
+can handle exceptions the user, or falls back to the default
+exception method of your Maypole application.
+
+
+=head3 handler
+
+This method sets up the class if it's not done yet, sets some
+defaults and leaves the dirty work to handler_guts.
+
+=head3 handler_guts
+
+This is the core of maypole. You don't want to know.
+
=head1 SEE ALSO
There's more documentation, examples, and a wiki at the Maypole web
my $package;
our $buffer;
+# Command line action
+CHECK {
+ if ( ( caller(0) )[1] eq "-e" ) {
+ $package->handler() == OK and print $buffer;
+ }
+}
+
sub import {
$package = $_[1];
$package->require;
unshift @{ $package . "::ISA" }, "Maypole::CLI";
}
-sub get_request { }
sub get_template_root { $ENV{MAYPOLE_TEMPLATES} || "." }
sub parse_location {
$package->handler() == OK and return $buffer;
}
-# Do it!
-CHECK {
- if ( ( caller(0) )[1] eq "-e" ) {
- $package->handler() == OK and print $buffer;
- }
-}
1;
For instance, a test script could look like this:
- use Test::More tests => 5;
+ use Test::More tests => 3;
use Maypole::CLI qw(BeerDB);
use Maypole::Constants;
$ENV{MAYPOLE_TEMPLATES} = "t/templates";
# Hack because isa_ok only supports object isa not class isa
isa_ok( (bless {},"BeerDB") , "Maypole");
- @ARGV = ("http://localhost/beerdb/");
- is(BeerDB->handler, OK, "OK");
- like($Maypole::CLI::buffer, qr/frontpage/, "Got the front page");
+ like(BeerDB->call_url("http://localhost/beerdb/"), qr/frontpage/, "Got the front page");
+
+ like(BeerDB->call_url("http://localhost/beerdb/beer/list"), qr/Organic Best/, "Found a beer in the list");
+
+=head1 METHODS
+
+=over
+
+=item call_url
+
+for use in scripts. takes an url as argument, and returns the buffer.
+
+=back
+
+
+=head1 Implementation
+
+This class overrides a set of methods in the base Maypole class to provide it's
+functionality. See L<Maypole> for these:
+
+=over
+
+=item get_template_root
+
+=item parse_args
+
+=item parse_location
+
+=item send_output
- @ARGV = ("http://localhost/beerdb/beer/list");
- is(BeerDB->handler, OK, "OK");
- like($Maypole::CLI::buffer, qr/Organic Best/, "Found a beer in the list");
+=back
+=cut
=item search
+The search action
+
+=back
+
=head1 Helper Methods
+=over
+
=item order
=item stringify_column
=item do_pager
+=item related_class
+
+Given an accessor name as a method, this function returns the class this accessor returns.
+
+=back
+
=cut
sub related {
sub template { die shift() . " didn't define a decent template method!" }
1;
+
+
+=head1 NAME
+
+Maypole::View::Base - Base cl
+
+=head1 DESCRIPTION
+
+This is the base class for Maypole view classes. This is an abstract class
+meant to define the interface, and can't be used directly.
+
+=head2 process
+
+This is the engine of this module. It populates all the relevant variables
+and calls the requested action.
+
+Anyone subclassing this for a different database abstraction mechanism
+needs to provide the following methods:
+
+=head2 template
+
+In this method you do the actual processing of your template. it should use L<paths>
+to search for components, and provide the templates with easy access to the contents
+of L<vars>. It should put the result in $r->{output} and return OK if processing was
+sucessfull, or populate $r->{error} and return ERROR if it fails.
+
+=head1 Other overrides
+
+Additionally, individual derived model classes may want to override the
+
+=head2 new
+
+The default constructor does nothing. You can override this to perform actions
+during view initialization.
+
+=head2 paths
+
+Returns search paths for templates. the default method returns factory, custom and
+<tablename> under the configured template root.
+
+=head2 vars
+
+returns a hash of data the template should have access to. The default one populates
+classmetadata if there is a class, as well as setting the data objects by name if
+there is one or more objects available.
+
+=head2 error
+
+
+=cut