X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FMaypole.pm;h=9a86489b8127d7cbb0914409d88ca0a415948415;hb=74800a709376d0ce878cabd9db6b3578c002606c;hp=b55f4f810ef18a0bed337f5ace24765868062914;hpb=9bbeafd23117d2b489a298cc002a97b133de17bd;p=maypole.git diff --git a/lib/Maypole.pm b/lib/Maypole.pm index b55f4f8..9a86489 100644 --- a/lib/Maypole.pm +++ b/lib/Maypole.pm @@ -5,7 +5,7 @@ use UNIVERSAL::require; use Apache::Constants ":common"; use strict; use warnings; -our $VERSION = "0.2"; +our $VERSION = "1.1"; __PACKAGE__->mk_classdata($_) for qw( config init_done view_object ); __PACKAGE__->mk_accessors ( qw( ar params query objects model_class args action template )); @@ -62,6 +62,7 @@ sub handler { $r->model_class->process($r); } else { # Otherwise, it's just a plain template. + $r->call_authenticate; # No harm in it delete $r->{model_class}; $r->{path} =~ s{/}{}; # De-absolutify $r->template($r->{path}); @@ -73,18 +74,18 @@ sub is_applicable { my $self = shift; my $config = $self->config; $config->{ok_tables} = {map {$_ => 1} @{$config->{display_tables}}}; - warn "We don't have that table ($self->{table})" - unless $config->{ok_tables}{$self->{table}}; + #warn "We don't have that table ($self->{table})" + # unless $config->{ok_tables}{$self->{table}}; return DECLINED() unless exists $config->{ok_tables}{$self->{table}}; # Does the action method exist? my $cv = $self->model_class->can($self->{action}); - warn "We don't have that action ($self->{action})" unless $cv; + #warn "We don't have that action ($self->{action})" unless $cv; return DECLINED() unless $cv; # Is it exported? $self->{method_attribs} = join " ", attributes::get($cv); - do { warn "$self->{action} not exported"; + do { # warn "$self->{action} not exported"; return DECLINED() } unless $self->{method_attribs} =~ /\bExported\b/i; return OK(); @@ -93,8 +94,8 @@ sub is_applicable { sub call_authenticate { my $self = shift; return $self->model_class->authenticate($self) if - $self->model_class->can("authenticate"); - return $self->authenticate(); + $self->model_class->can("authenticate"); + return $self->authenticate($self); # Interface consistency is a Good Thing } sub additional_data {} @@ -133,9 +134,9 @@ for the designers to customize, and then write an Apache handler like this: package ProductDatabase; - use base 'Maypole'; + use base 'Apache::MVC'; __PACKAGE__->set_database("dbi:mysql:products"); - BeerDB->config->{uri_base} = "http://your.site/catalogue/"; + ProductDatabase->config->{uri_base} = "http://your.site/catalogue/"; ProductDatabase::Product->has_a("category" => ProductDatabase::Category); # ... @@ -190,6 +191,9 @@ subclass the model class, and configure your class slightly differently: $r->template("template_name"); } +Then your top-level application package should change the model class: +(Before calling C) + ProductDatabase->config->{model_class} = "ProductDatabase::Model"; (The C<:Exported> attribute means that the method can be called via the