X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FApache%2FMVC.pm;h=68a9927bf113ae421c1e205f8b87f0f334fece46;hb=a0f5a455f933d562b30d9feb613098fb7ddc85b6;hp=42d0d9102bbf4533526faa53f97dbe421b467e8d;hpb=58398cbb7b75bf3106e8503b81ee782178c248c3;p=maypole.git diff --git a/lib/Apache/MVC.pm b/lib/Apache/MVC.pm index 42d0d91..68a9927 100644 --- a/lib/Apache/MVC.pm +++ b/lib/Apache/MVC.pm @@ -50,7 +50,9 @@ sub init { $config->{display_tables} ||= [ $class->config->{loader}->tables ]; for my $subclass (@{$config->{classes}}) { no strict 'refs'; - push @{$subclass."::ISA"}, $class->config->{model}; + unshift @{$subclass."::ISA"}, $class->config->{model}; + $config->{model}->adopt($subclass) + if $config->{model}->can("adopt"); } $class->view_object($class->config->{view}->new); $class->init_done(1); @@ -90,32 +92,35 @@ sub get_request { sub parse_location { my $self = shift; - my $uri = $self->{ar}->uri(); - my $loc = $self->{ar}->location(); - $uri =~ s/^$loc//; + my $uri = $self->{ar}->path_info(); my @pi = split /\//, $uri; shift @pi while @pi and !$pi[0]; $self->{table} = shift @pi; $self->{action} = shift @pi; $self->{args} = \@pi; - $self->{params} = $self->{ar}->content; + $self->{params} = { $self->{ar}->content }; } sub is_applicable { my $self = shift; my $config = $self->config; - my %ok = map {$_ => 1} @{$config->{display_tables}}; - return DECLINED() unless exists $ok{$self->{table}}; + $config->{ok_tables} = {map {$_ => 1} @{$config->{display_tables}}}; + 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? + # XXX We should set the method class to the class for the table my $cv = $self->model_class->can($self->{action}); + 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"; return DECLINED() - unless $self->{method_attribs} =~ /\bExported\b/i; + } unless $self->{method_attribs} =~ /\bExported\b/i; return OK(); }