Dave05 has asked for the wisdom of the Perl Monks concerning the following question:
This thing is a web site, running under HTML::Mason. I have a MyApp::Person object representing a logged in user. I can happily use the object to run through all the registered users in my database, and call methods to print out a list of names for instance.
But when I have a specific user logged in, and identified via a cookie, I get this error when trying to call methods off the user stored in the cookie (the cookie stores an ID string, which identifies a file on the server that holds the user data which is used to initialise the $user object):
Can't locate object method "full_name" via package "MyApp::Person" (perhaps you forgot to load "MyApp::Person"?)
Here's the thing. If I check %INC, MyAPP::Person _is_ loaded.
Also: ref($user) returns MyApp::Person
The next thing: if I run a $user->can('full_name'), it can't.
Next: in fact, my $user can't do _any_ of the MyApp::Person methods.
BUT: if I stick a dummy variable in MyApp/Person.pm (our $dummy_true = 1;), then
I _can_ successfully read the dummy variable (via $MyApp::Person::dummy_true).
So basically, I can access the MyApp::Person namespace, but I can't use $user to get hold of any methods defined in there, despite ref($user) == MyApp::Person
One specific question I'd like to ask is: how can I check the package my code is currently running under?
But what I'd really like is suggestions as to where to look next.
D.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Lost methods
by Chmrr (Vicar) on Nov 26, 2002 at 12:32 UTC | |
Re: Lost methods
by Dave05 (Beadle) on Nov 26, 2002 at 15:16 UTC | |
Re: Lost methods
by Dave05 (Beadle) on Nov 26, 2002 at 15:04 UTC | |
by Abigail-II (Bishop) on Nov 26, 2002 at 15:37 UTC | |
by Dave05 (Beadle) on Nov 26, 2002 at 16:06 UTC | |
Re: Lost methods
by fruiture (Curate) on Nov 26, 2002 at 12:20 UTC | |
Re: Lost methods
by Abigail-II (Bishop) on Nov 26, 2002 at 12:20 UTC | |
Re: Lost methods
by mce (Curate) on Nov 26, 2002 at 12:25 UTC |