Hello,

       I am trying to "Export" methods that are inherited from a parent 
class. But I keep getting the "Invalid CODE attribute :Exported" and yes I 
have my application->setup method wrapped in a Begin block.

I have a module called Estimate.pm

it begins like

package Estimate;


sub step1 :Exported {
  my ($class, $r) = @_;

  ... code here
  ... code here

$r->template($some_template);
}

Now I have  a series of different types of estimates I want to inherit from 
estimate. Like

WindowEstimate, PaintingEstimate

package WindowEstimate;
use base qw (Maypole::Model::CDBI Estimate);

package PaintingEstimate;
use base qw (Maypole::Model::CDBI Estimate);

Now if I try to run [%base%]/app/PaintingEstimate/step1

I get the Invalid CODE attribute.

so I tried

package Estimate;
use base qw (Maypole::Model::CDBI);

sub step1 :Exported {
   my (yada yada yada)
}

package PaintingEstimate;
use base qw(Estimate);

now if I run [%base%]/app/PaintingEstimate/step1 I get the same thing 
Invalid attribute Error

So basically is there anyway I can inherit from a parent class so that the 
:Exported attribute will be accepted. I even tried "use attributes" in the 
Estimate class still didn't work.

The only way I've been able to get this to work is like

package Estimate;

sub step1 {
   my ($class, $e_class, $r) = @_;

   #do some stuff and then return an updated $r

   return $r;
}

package PaintingEstimate;
use base qw (Maypole::Model::CDBI)

use Estimate;

sub step1 :Exported {
my ($class, $r) = @_;

my $e = new Estimate;

my $r = $e->step1;

$r->template("some template");
}

Any suggestions?



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Maypole-users mailing list
Maypole-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/maypole-users

Reply via email to