[PerlChina] 关于Perl的attributes的用法

Mike.G hylinux at gmail.com
Sun Sep 6 09:17:17 PDT 2009


今天在使用一个C:A的插件的时候碰到一个问题:
C:A:Plugin::ActionDispatch

这个模块是使用attributes的特性来判断runmode的

有个问题是
例如:
when I define some runmode in parent class.
just like

package  Myparentclass;
use base qw/CGI::Applicatin/;
use CGI::Application::plugin::ActionDispatch;

sub cgiapp_prerun {
     my $this = shift;
     if ( some condition ) {
       $this->prerun_mode('mode1');

    }

}


sub mode1:Runmode {
 it is here

}

1;

and in
Child Class

package MyChild;
use base qw/Myparentclass/;



1;

when the "some condition" true,  in parent class, it will be run mode1,
but it doesn't work:
said:

No such run mode 'showcity' at /home/ghw/myperl/in-marry/app/store line 13

但是把这个runmode定义在store的模块中可以的。
所以我猜测是C:A:Plugin::ActionDispatch中有问题了。
打开源代码看了一下。发现整个核心是使用attributes来做的。

一直没明白attributes的作用。
哪位大大可以讲讲?
看了一下perldoc,不太明白。

谢谢


Mike.G
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/china-pm/attachments/20090907/e19f86fd/attachment.html>


More information about the China-pm mailing list