今天在使用一个C:A的插件的时候碰到一个问题:<br>C:A:Plugin::ActionDispatch<br><br>这个模块是使用attributes的特性来判断runmode的<br><br>有个问题是<br>例如:<br>when I define some runmode in parent class.<br>just like <br><br>package&nbsp; Myparentclass;<br>
use base qw/CGI::Applicatin/;<br>use CGI::Application::plugin::<div id=":x8" class="ii gt">ActionDispatch;<br><br>sub cgiapp_prerun {<br>&nbsp;&nbsp;&nbsp;&nbsp; my $this = shift;<br>&nbsp;&nbsp;&nbsp;&nbsp; if ( some condition ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $this-&gt;prerun_mode(&#39;mode1&#39;);<br>
<br>
&nbsp;&nbsp;&nbsp; }<br><br>}<br><br><br>sub mode1:Runmode {<br>&nbsp;it is here<br><br>}<br><br>1;<br><br>and in <br>Child Class<br><br>package MyChild;<br>use base qw/Myparentclass/;<br><br><br><br>1;<br><br>when the &quot;some condition&quot; true,&nbsp; in parent class, it will be run mode1,<br>

but it doesn&#39;t work:<br>said:<br><pre>No such run mode &#39;showcity&#39; at /home/ghw/myperl/in-marry/app/store line 13<br><br>但是把这个runmode定义在store的模块中可以的。<br>所以我猜测是C:A:Plugin::ActionDispatch中有问题了。<br>打开源代码看了一下。发现整个核心是使用attributes来做的。<br>
<br>一直没明白attributes的作用。<br>哪位大大可以讲讲?<br>看了一下perldoc,不太明白。<br><br>谢谢<br><br><br>Mike.G<br><br></pre></div><br>