]> git.decadent.org.uk Git - maypole.git/blobdiff - lib/Maypole.pm
Refactor out path parsing.
[maypole.git] / lib / Maypole.pm
index 62083e82a2c1a8423aa63f2ea9fa13f5dd73ab49..fd11fbe9d3862760bfeacd4398ca5604bb1218f0 100644 (file)
@@ -4,7 +4,7 @@ use attributes ();
 use UNIVERSAL::require;
 use strict;
 use warnings;
-our $VERSION = "1.1";
+our $VERSION = "1.3";
 __PACKAGE__->mk_classdata($_) for qw( config init_done view_object );
 __PACKAGE__->mk_accessors ( qw( ar params query objects model_class
 args action template ));
@@ -28,6 +28,7 @@ sub setup {
     my $config = $calling_class->config;
     $config->{model} ||= "Maypole::Model::CDBI";
     $config->{model}->require;
+    die "Couldn't load the model class $config->{model}: $@" if $@;
     $config->{model}->setup_database($config, $calling_class, @_);
     for my $subclass (@{$config->{classes}}) {
         no strict 'refs';
@@ -42,6 +43,7 @@ sub init {
     my $config = $class->config;
     $config->{view}  ||= "Maypole::View::TT";
     $config->{view}->require;
+    die "Couldn't load the view class $config->{view}: $@" if $@;
     $config->{display_tables} ||= [ @{$class->config->{tables}} ];
     $class->view_object($class->config->{view}->new);
     $class->init_done(1);
@@ -116,6 +118,16 @@ sub additional_data {}
 
 sub authenticate { return OK }
 
+sub parse_path {
+    my $self = shift;
+    $self->{path} ||= "frontpage";
+    my @pi = split /\//, $self->{path};
+    shift @pi while @pi and !$pi[0];
+    $self->{table} = shift @pi;
+    $self->{action} = shift @pi;
+    $self->{args} = \@pi;
+}
+
 =head1 NAME
 
 Maypole - MVC web application framework
@@ -245,6 +257,12 @@ sub get_request { }
 sub parse_location { die "Do not use Maypole directly; use Apache::MVC or similar" }
 sub send_output{ die "Do not use Maypole directly; use Apache::MVC or similar" }
 
+=head1 SEE ALSO
+
+There's more documentation, examples, and a wiki at the Maypole web site:
+
+http://maypole.simon-cozens.org/
+
 =head1 AUTHOR
 
 Simon Cozens, C<simon@cpan.org>