CAP好像停止开发了啊。<br>我选型的时候也看看了。<br>但是看到最后的更新日期太老了。<br>就没有采用。<br><br>Mike.G<br><br><br><div class="gmail_quote">2008/6/11 Qiang <<a href="mailto:shijialee@gmail.com">shijialee@gmail.com</a>>:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="Wj3C7c">Mike.G wrote:<br>
> Hi, list<br>
> I got one issue when I use the plugin CGI::Application::Plugin:<br>
> :Session<br>
><br>
> I have a parent package(Class), named "FWebApp",<br>
> and this class extends the CGI::Application.<br>
> I did some setting work in the method cgiapp_init<br>
><br>
> like this:<br>
><br>
> sub cgiapp_init {<br>
> my $this = shift;<br>
><br>
> #get the database configuration<br>
> my $datasource = $this->cfg('data_source');<br>
> my $data_user = $this->cfg('data_username');<br>
> my $data_auth = $this->cfg('data_userauth');<br>
> my $attr = $this->cfg('data_attr');<br>
><br>
> #configuration the Database<br>
> $this->dbh_config($datasource,<br>
> $data_user,<br>
> $data_auth,<br>
> $attr);<br>
><br>
><br>
> #configuration the Session<br>
> $this->session_config(<br>
> CGI_SESSION_OPTIONS => [<br>
> "driver:mysql",<br>
> $this->query,<br>
> {<br>
> Handle=>$this->dbh<br>
> }],<br>
><br>
> COOKIE_PARAMS => {<br>
> -domain => $this->cfg('site_domain'),<br>
> -expires=>'+40m',<br>
> -path=>'/',<br>
> -secure=>1,<br>
> },<br>
><br>
> );<br>
><br>
> #set the template path<br>
> $this->tmpl_path($this->cfg('template_path'));<br>
><br>
><br>
><br>
> and the session configuration look like is ok.<br>
><br>
> and so, just now, i assume I have a action: it is register .<br>
> so, I will write a new module named:<br>
><br>
> package FWebApp::Register;<br>
> =head1 NAME<br>
><br>
> FWebApp::Register - show the register page<br>
><br>
> =head1 SYNOPSIS<br>
><br>
> extends the Class FWebApp,<br>
> show the register page<br>
><br>
> =cut<br>
> use strict;<br>
> use warnings;<br>
> use base qw/FWebApp/;<br>
> use CGI::Application::Plugin::AutoRunmode;<br>
> use CGI::Application::Plugin::DBH qw/dbh_config dbh/;<br>
> use CGI::Application::Plugin::ConfigAuto qw/cfg/;<br>
> use CGI::Application::Plugin::Session;<br>
><br>
><br>
> # the default requirement mode<br>
> # show the register page.<br>
> sub show_register: StartRunmode {<br>
> my $this = shift;<br>
><br>
> # if that user had login, we will jump to home page<br>
> my $template = undef;<br>
> if ( $this->session->param('loginname') ) {<br>
> $template = $this->load_tmpl('had_login.html');<br>
> $template->param('HOMEPAGE', 'index.html');<br>
> } else {<br>
> $template = $this->load_tmpl('register.html');<br>
> }<br>
><br>
><br>
> return $template->output;<br>
><br>
> }<br>
><br>
><br>
><br>
><br>
> 1;<br>
><br>
><br>
> it is extends FWebApp, but when I had prepared a script:<br>
> like this:<br>
> #!/usr/local/bin/perl -w -T<br>
> use strict;<br>
> use lib qw(. ../lib);<br>
> use CGI::Application::Plugin::ConfigAuto;<br>
> use CGI::Carp qw/fatalsToBrowser warningsToBrowser/;<br>
> use FWebApp::Register;<br>
><br>
> my $app = FWebApp::Register->new(<br>
> PARAMS => {<br>
> cfg_file => 'config.pl' } );<br>
><br>
> $app->run;<br>
><br>
><br>
> _*when I refresh that script, we always got the difference session id,<br>
</div></div>> why?*_<br>
><br>
><br>
<br>
我用 CGI::Application 但并不怎么使用 CGI::Application::Plugin::Session<br>
(缩为 CAP::Session)。 大致看了你的例子, script 每次运行都会调用 sub<br>
show_register 里的 $this->session->param('loginname') 来检查用户是否已登<br>
录,如果没有登录,$this->session 的调用就会生成一个新的 CGI::Session<br>
object 因此生产一个新 session id. 你的 script 没有登录的那部分,即每次都<br>
是一个非登录的用户访问,自然每次都拿到一个新 session id 了。<br>
<br>
另外,CGI::Application 里一般都在 base class 里把要用到的 CAP 的 plugins<br>
load 进去,例如 CAP::DBH, CAP::ConfigAuto 等,没有必要在子包里在 use 了。<br>
<br>
> thanks<br>
><br>
><br>
> Mike.G<br>
<br>
HTH,<br>
<font color="#888888"><br>
Qiang<br>
_______________________________________________<br>
China-pm mailing list<br>
<a href="mailto:China-pm@pm.org">China-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/china-pm" target="_blank">http://mail.pm.org/mailman/listinfo/china-pm</a></font></blockquote></div><br>