[Catalyst] problem with Authentication::CDBI, or something else?

samwyse samwyse at gmail.com
Fri Jun 10 03:54:20 CEST 2005


### The following code was copied pretty much verbatim from
Catalyst::Manual::Cookbook:

package MyApp;

use strict;
use Catalyst qw/ -Debug Static Session::FastMmap Authentication::CDBI /;

our $VERSION = '0.01';

MyApp->config(
	name => 'MyApp',
	authentication => {
		user_class => 'MyApp::M::MyCDBI::User.pm',
		user_field => 'email',
		password_field => 'password',
	},
);

MyApp->setup;

sub login : Local {
    my ( $self, $c ) = @_;
    if ($c->req->params->{username}) {   ### line 41 ###
	    $c->session_login(
		    $c->req->params->{username},
		    $c->req->params->{password} );


### When I run it (using 'myself' as the username), I get the
following traceback:

Caught exception "Can't locate object method "req" via package
"myself" (perhaps you forgot to load "myself"?) at
/home/dentos/MyApp/script/../lib/MyApp.pm line 41."

Request

bless( {
                 'protocol' => 'HTTP/1.1',
                 'headers' => bless( {
                                       'user-agent' => 'Mozilla/5.0
(Windows; U; Windows NT 5.0; en-US; rv:1.7.8) Gecko/20050511
Firefox/1.0.4',
                                       'connection' => 'keep-alive',
                                       'keep-alive' => '300',
                                       'accept' =>
'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
                                       'accept-language' => 'en-us,en;q=0.5',
                                       'cookie' =>
'session=cea6236091f39f4beb1ea57522f8b181',
                                       'accept-encoding' => 'gzip,deflate',
                                       'host' => 'localhost:3000',
                                       'accept-charset' =>
'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
                                       'referer' =>
'http://localhost:3000/login'
                                     }, 'HTTP::Headers' ),
                 'snippets' => [],
                 'secure' => 0,
                 'hostname' => undef,
                 'uploads' => {},
                 'user' => undef,
                 'method' => 'GET',
                 'address' => '127.0.0.1',
                 'base' => 'http://localhost:3000/',
                 'cookies' => {
                                'session' => bless( {
                                                      'value' => [
                                                                  
'cea6236091f39f4beb1ea57522f8b181'
                                                                 ],
                                                      'name' => 'session',
                                                      'path' => '/'
                                                    }, 'CGI::Cookie' )
                              },
                 'match' => 'login',
                 'path' => 'login',
                 'parameters' => {
                                   'password' => 'xyzzy',
                                   'username' => 'myself'
                                 },
                 'action' => 'login',
                 'arguments' => []
               }, 'Catalyst::Request' )

Response

bless( {
                 'body' => '',
                 'cookies' => {},
                 'headers' => bless( {
                                       'content-type' => 'text/html',
                                       'x-catalyst' => '5.23',
                                       'content-length' => 0
                                     }, 'HTTP::Headers' ),
                 'status' => 200
               }, 'Catalyst::Response' )

Stash

{}

MyApp on Catalyst 5.23

### I just checked, and at line 41 $c is MyApp=HASH(0x10dcaefc). 
Anyone have any ideas?



More information about the Catalyst mailing list