On 11/4/05, Dave Howorth <[EMAIL PROTECTED]> wrote:
> On Thu, 2005-11-03 at 19:18 -0600, Peter Speltz wrote:
> > On 11/3/05, David Baird <[EMAIL PROTECTED]> wrote:
> > <snip>
> > > I'm just wondering if it might also cut down on the phantom errors.
>
> > Don't have time to look in all the rest however, what exactly were the
> > cases of phantom errors?   If I recall I think mine were from the
> >
> > BeerDB::Beer->require;
> >
> > statements in my driver.  By default it does not die if Beer.pm has
> > errors.   So I changed all my staments to
> > BeerDB::Beer->require || die Universal::require::ERROR;
> > and dont think I have had them since.
>
> I think we've discussed this before but I don't remember the outcome.
> Anyway, here's code from my loader's version of setup, which
> distinguishes between compile errors and subclasses that don't have
> separate files:
>
>     # Load any external files for the model base class or subclasses
>     # (e.g. BeerDB/DBI.pm or BeerDB/Beer.pm) based on code borrowed from
>     # Maypole::Plugin::Loader and Class::DBI.
>     for my $model_class ( $model, @{ $config->classes } ) {
>         if ( $model_class->require ) {
>             warn "Loaded external module for '$model_class'\n"
>                 if $self->debug > 1;
>         } else {
>             (my $filename = $model_class) =~ s!::!/!g;
>             die "Loading '$model_class' failed: [EMAIL PROTECTED]" .
>                     $UNIVERSAL::require::ERROR
>                 unless $@ =~ /Can't locate \Q$filename\E\.pm/;
>             warn "Didn't find external module for '$model_class'\n"
>                 if $self->debug > 1;
>         }
>
>         $model->adopt($model_class) if $model->can('adopt');
>     }
>
> Cheers, Dave

Good stuff, it gives better diagnostics than my code, and I had it
after the call to adopt(), but it should be before.

d.


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Maypole-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maypole-devel

Reply via email to