[cgiapp] $self-param misunderstanding

2002-06-13 Thread fyzicle feecher

I'm clearly not understanding something here.  I'm trying to use $self-param() the
same way it's used in the docs.  The print statement in setup prints mydbh instead
of the DBI reference.  If I uncomment the $dog lines, it prints the DBI reference
fine.

I'm in WinXP with ActiveState Perl 5.6.1 and CGI::Application 2.4.  It behaves
identically if I run it through IIS or from the command line.

Thanks for any help and congrats on a very cool and well-designed module.  I'm going
to scour the mailing list when I get a chance.

Here's a stripped version of my app module:

#
package MyApp;
use base 'CGI::Application';
use strict;

use CGI qw/:standard/;
use DBI;
use HTML::Template;

sub setup {
   my $self = shift;
   $self-start_mode('page1');
   $self-run_modes(
'page1' = 'page1'
   );
   
   $self-param('mydbh' = DBI-connect('dbi:ODBC:TestDatabase'));
   print $self-param('mydbh') . \n\n;

#  my $dog = DBI-connect('dbi:ODBC:TestDatabase');
#  print $dog;
}

sub page1 {
   my $self = shift;
   my $dbh = $self-param('mydbh');
   my $template = HTML::Template-new(filename = 'page1.tmpl');
   
   my $pos_ref = $dbh-selectcol_arrayref(select Position from Positions);
   # do other stuff

   return $template-output;
}
1;
#

and here's my instance script:

#
#!/usr/bin/perl -w
use strict;
use MyApp;
my $myapp = MyApp-new();
$myapp-run();
#

__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

-
Web Archive:  http://www.mail-archive.com/cgiapp@lists.vm.com/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: [cgiapp] $self-param misunderstanding

2002-06-13 Thread Brett Sanger

 use CGI qw/:standard/;

Don't use this, CGI::App handles CGI for you.  (you can get the CGI object
via $self-query())

I suspect param() is getting mangled somewhere along the line.  Remove the
use CGI line and try again.



-
Web Archive:  http://www.mail-archive.com/cgiapp@lists.vm.com/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: [cgiapp] $self-param misunderstanding

2002-06-13 Thread fyzicle feecher

That did it.  I figured it was something simple.

Thanks!

--- Brett Sanger [EMAIL PROTECTED] wrote:
  use CGI qw/:standard/;
 
 Don't use this, CGI::App handles CGI for you.  (you can get the CGI object
 via $self-query())
 
 I suspect param() is getting mangled somewhere along the line.  Remove the
 use CGI line and try again.
 

__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

-
Web Archive:  http://www.mail-archive.com/cgiapp@lists.vm.com/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]