domje has asked for the wisdom of the Perl Monks concerning the following question:
Hello, Monks! I'm humbly seeking some guidance in order to find some peace...
I'm developing my own nuts-n-bolts CMS-like software for a few intranet applications. The issue I'm encountering is that when I try to use a module I've written via one of my Mason pages I'm getting a "Can't locate object method 'foo' via package 'bar'..."
This works just fine, mind you in external scripts. I can guess it's something with the way I'm blessing the reference? I don't know. My 'new' sub works and it returns a reference.
However...If I call another routine in the module I get the error mentioned above. Where oh where am I going wrong? Here's the Mason code (I'm declaring the database handle as a global in the autohandler):
There is litterally nothing else in this file but a paragraph tag at the bottom with the word "testing" in it.... <%once> use lib '/var/www/nlt/libs'; use CMS::Users; my $u = CMS::Users->new(); $u->SetDBH($mysql_db_handle); print $u->GetUserList(); </%once> ...
Here's some code I threw together to troubleshoot the problem:
Strangely enough the SetDBH routine works without incident. While GetUserList produces the error. What gives? I'm losing my mind and can't seem to figure out why it's not working. Thank you all in advance for reading through this (if you are still reading). --dompackage CMS::Users; use Digest::MD5 qw(md5); use CGI; sub new { my $class = shift; my $self = { }; bless $self, $class; return $self; } sub SetDBH { my ($self, $dbh) = @_; if ($dbh) { $self->{DBH} = $dbh; return 1; } else { return undef; } } sub GetUserList { my ($self,%args) = @_; return "Sub call worked. I'm from: $self"; } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: My module's methods aren't working under Mason pages?
by duyet (Friar) on Aug 10, 2011 at 06:29 UTC | |
by Anonymous Monk on Aug 10, 2011 at 07:14 UTC | |
by duyet (Friar) on Aug 10, 2011 at 08:25 UTC | |
by Anonymous Monk on Aug 10, 2011 at 09:06 UTC | |
by Anonymous Monk on Aug 11, 2011 at 20:59 UTC | |
by Anonymous Monk on Aug 12, 2011 at 01:43 UTC |