[Maypole] authentication for plain templates

Jason Kohles email@jasonkohles.com
Tue, 6 Jul 2004 00:54:31 -0400


Following up to my earlier message, it seems that a simple template
(such as the example 'frontpage') can not be authenticated for similar
reasons, your authenticate() sub will never be called if you are calling
a template which is not associated with a table.  I've patched my
version of Maypole with this patch, which solves the problem for me, and
hopefully for others...

*** Maypole.pm  Tue Jul  6 00:29:28 2004
--- /usr/lib/perl5/site_perl/5.6.1/Maypole.pm   Tue Jul  6 00:57:19 2004
***************
*** 63,78 ****
  sub handler_guts {
      my $r = shift;
      $r->model_class($r->config->{model}->class_of($r, $r->{table}));
!     my $status = $r->is_applicable;
      if ($status == OK) {
-         $status = $r->call_authenticate;
-         if ($r->debug and $status != OK and $status != DECLINED) {
-             $r->view_object->error($r,
-                 "Got unexpected status $status from calling authentication");
-         }
-         return $status unless $status == OK;
-         $r->additional_data();
-
          $r->model_class->process($r);
      } else {
          # Otherwise, it's just a plain template.
--- 63,78 ----
  sub handler_guts {
      my $r = shift;
      $r->model_class($r->config->{model}->class_of($r, $r->{table}));
!
!     my $status = $r->call_authenticate;
!     if ($r->debug and $status != OK and $status != DECLINED) {
!         $r->view_object->error($r,
!             "Got unexpected status $status from calling authentication");
!     }
!     return $status unless $status == OK;
!     $r->additional_data();
!     $status = $r->is_applicable;
      if ($status == OK) {
          $r->model_class->process($r);
      } else {
          # Otherwise, it's just a plain template.

-- 
Jason Kohles                         A witty saying proves nothing.
email@jasonkohles.com                   -- Voltaire (1694 - 1778)
http://www.jasonkohles.com/