[Catalyst] Nonsensical Problem with DBIx ResultSet

Nicholas Wehr catalyst at bionikchickens.com
Thu Jul 8 15:56:02 GMT 2010


I'd suggest using the debugger and breaking there; examine the data
structure.

insert this at line 39:
 $DB::single=3D2;

launch your app with the debug flag (not apache - standalone)
 perl -d ~libki/LibkiServer/script/LibkiServer_server.pl -d

then run these debugger commands:
 x ref $user->session

is the structure an object? HASH? if it's a hash, try this:
 x $user->session->{client}
 x $user->session->{client}->clientname

... and so on. the debugger is your quickest way to uncovering the mysteries
of your data

good luck!
-nw


On Thu, Jul 8, 2010 at 7:57 AM, Kyle Hall <kyle.m.hall at gmail.com> wrote:

> Hello all,
>   I'm the developer of a FOSS kiosk management system, Libki. I'm in the
> early stages of a complete rewrite using Catalyst for the web-based
> administration interface. This is my first time using Catalyst, but I'm v=
ery
> excited by the possibilities! I'm having a very strange issue with my
> resultsets. For example, I have three tables, a users table, a clients
> table, and a sessions table that connects the user to a client.
>
> I grab my users from the database, with any session/client data if the us=
er
> is currently logged in to a client kiosk. I am prefetching the session and
> client table data.
>
> my $user_rs =3D $c->model('DB::User')->search( {}, { prefetch =3D> { sess=
ion =3D>
> 'client' } } );
>
> Now I want to loop through it.
>
>     my $row =3D 0;
>     my @row_data;
>
>     while ( my $user =3D $user_rs->next() ) {
>         my $user_id =3D $user->id;
>
>         warn $user->session->client->clientname;
>
>         my $single_row =3D {
>             cell =3D> [
>                 $user->id,
>                 $user->username,
>                 $user->minutes,
>                 $user->status,
>                 $user->is_troublemaker,
>                 $user->session->client->clientname;
>             ]
>         };
>         push( @row_data, $single_row );
>     }
>
>
> Now, if I try to access any of the other tables, I get an error:
> [error] Caught exception in LibkiServer::Controller::Admin::REST->users
> "Can't call method "client" on an undefined value at
> /home/libki/LibkiServer/script/../lib/LibkiServer/Controller/Admin/REST.pm
> line 40."
>
> I don't know why I get this error, but the really crazy part is *the warn
> still works*:
> Client Name: testclient1 at
> /home/libki/LibkiServer/script/../lib/LibkiServer/Controller/Admin/REST.pm
> line 40.
>
> If anyone can help me out, I'd be eternally grateful.
>
> Thanks,
> Kyle
>
> http://www.kylehall.info
> Mill Run Technology Solutions ( http://millruntech.com )
> Crawford County Federated Library System ( http://www.ccfls.org )
> Meadville Public Library ( http://www.meadvillelibrary.org )
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100708/04cb5=
bc4/attachment.htm


More information about the Catalyst mailing list