From: biopete Date: Mon, 12 Jun 2006 20:34:32 +0000 (+0000) Subject: Now request model_class is not set unless the model class is a Maypole::Model::Base. X-Git-Tag: 2.11~26 X-Git-Url: https://git.decadent.org.uk/gitweb/?p=maypole.git;a=commitdiff_plain;h=58c9595d95477fa806c7876aa7bf80d1908bd22d Now request model_class is not set unless the model class is a Maypole::Model::Base. git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@494 48953598-375a-da11-a14b-00016c27c3ee --- diff --git a/lib/Maypole.pm b/lib/Maypole.pm index 770467a..19e9cec 100644 --- a/lib/Maypole.pm +++ b/lib/Maypole.pm @@ -652,9 +652,17 @@ sub __get_mime_type { sub __load_request_model { my ($self) = @_; - $self->model_class( $self->config->model->class_of($self, $self->table) ); + # We may get a made up class from class_of + my $mclass = $self->config->model->class_of($self, $self->table); + if ( eval {$mclass->isa('Maypole::Model::Base')} ) { + $self->model_class( $mclass ); + } + elsif ($self->debug) { + warn "\n***Warning: No $mclass class appropriate to set as request model : $@***\n" + } } + # is_applicable() returned false, so set up a plain template. Model processing # will be skipped, but need to remove the model anyway so the template can't # access it. diff --git a/t/01basics.t b/t/01basics.t index 7da48b2..87c9643 100644 --- a/t/01basics.t +++ b/t/01basics.t @@ -1,6 +1,6 @@ #!/usr/bin/perl -w use Test::More; -use lib 'ex'; # Where BeerDB should live +use lib '../ex'; # Where BeerDB should live BEGIN { $ENV{BEERDB_DEBUG} = 2;