还是得需要各位提点一下。主要是到底是怎么用的。
其实C:A::Plugin::ActionDispatch倒是一个实例,可惜没怎么看明白。
好像是根据attributes调用相应的设置好的子过程。
主要是attributes会取得一个列表,然后匹配。
另外代码里需要的功能倒是搞定了。
主要是C:A::Plugin::ActionDispatch没有打断原来的model
2009/9/7 Mike.G <hylinux@gmail.com>
今天在使用一个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
没有评论:
发表评论