Straight templates (Was: Re: [Maypole] model_class issues on 1.7->2.x upgrade?)

Jesse Sheidlower jester@panix.com
Fri, 3 Dec 2004 23:20:23 -0500


On Thu, Nov 18, 2004 at 01:03:36PM -0800, Peter Speltz wrote:
> 
> --- Jesse Sheidlower <jester@panix.com> wrote:
> 
> > 
> > Before I spend too much time debugging this, I thought someone
> > might have run into this and could help out.
> > 
> > I just upgraded Maypole from 1.7 to 2.04. Several applications
> > were unaffected, but one relatively complex one, which has some
> > authentication juju going on, had problems. I'm now throwing
> > errors of the sort:
> > 
> >   caught authenticate error: Can't call method "can" on an undefined
> >   value at...
> > 
> > with the relevant line, in the main module, being
> > 
> >   return $r->model_class->sub_authenticate($r)
> >    if $r->model_class->can("sub_authenticate");
> > 
> 
> What's the main module? You're driver?   Are you going to a page that doesn't
> have a model class associated with it like a straight template?   Wrap above
> code in an "if ($r->model_class) { warn "No model classs in sub authenticate; 
> .. . } and see if everything works ok. Check error log for warnings and see
> what situations you get the warning. 

Just coming back to this after some time working on the real $JOB.

Indeed, this was only happening on the frontpage template; anything
associated with a model class works fine.

Which leads me to two questions:

1. What changed from 1.7 to 2.x so that visiting such a page no longer
works, and more to the point what do I need to do under 2.x so that
visits to such a page don't fail? Is there a way to default things to
the base model class if there's no other?

2. I hadn't realized you can deliberately go to a straight template
page. In my apps when I have a plain template, I've been doing
things like:

sub about_this_site :Exported {
  my ($self, $r);
  $r->{template} = "about_this_site";
}

But perhaps there's a much better way.

Thanks.

Jesse Sheidlower