From 74800a709376d0ce878cabd9db6b3578c002606c Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Sat, 28 Feb 2004 10:59:58 +0000 Subject: [PATCH] Miscellaneous fixes. git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@79 48953598-375a-da11-a14b-00016c27c3ee --- lib/Apache/MVC.pm | 2 +- lib/Maypole.pm | 13 +++++++------ lib/Maypole/Model/CDBI.pm | 1 + lib/Maypole/View/TT.pm | 1 - 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/Apache/MVC.pm b/lib/Apache/MVC.pm index d43e292..0b1c873 100644 --- a/lib/Apache/MVC.pm +++ b/lib/Apache/MVC.pm @@ -15,7 +15,7 @@ sub parse_location { $self->{path} = $self->{ar}->uri; my $loc = $self->{ar}->location; no warnings 'uninitialized'; - $self->{path} =~ s/^$loc?\///; + $self->{path} =~ s/^($loc)?\///; $self->{path} ||= "frontpage"; my @pi = split /\//, $self->{path}; shift @pi while @pi and !$pi[0]; diff --git a/lib/Maypole.pm b/lib/Maypole.pm index 4e551eb..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 = "1.0"; +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(); @@ -133,7 +134,7 @@ 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"); ProductDatabase->config->{uri_base} = "http://your.site/catalogue/"; ProductDatabase::Product->has_a("category" => ProductDatabase::Category); diff --git a/lib/Maypole/Model/CDBI.pm b/lib/Maypole/Model/CDBI.pm index 34aa741..0be76f9 100644 --- a/lib/Maypole/Model/CDBI.pm +++ b/lib/Maypole/Model/CDBI.pm @@ -56,6 +56,7 @@ sub do_edit :Exported { } sub delete :Exported { + return shift->SUPER::delete(@_) if caller ne "Maypole::Model::Base"; my ($self, $r) = @_; $_->SUPER::delete for @{ $r->objects || [] }; $r->objects([ $self->retrieve_all ]); diff --git a/lib/Maypole/View/TT.pm b/lib/Maypole/View/TT.pm index 6149434..47999a4 100644 --- a/lib/Maypole/View/TT.pm +++ b/lib/Maypole/View/TT.pm @@ -12,7 +12,6 @@ sub new { bless {}, shift } # Not worth having sub _tt { my ($self, $r) = @_; my $root = $r->{ar}->document_root . "/". $r->{ar}->location; - warn "Root was $root"; Template->new({ INCLUDE_PATH => [ $root, ($r->model_class && File::Spec->catdir($root, $r->model_class->moniker)), -- 2.39.5