Right - I have a plugin that is essentially very simple - we'll use the blog example from previous thread.

I have created it with one Exported method (for example blog) which stores the object in the calling objects private hash ie:

--- snip ---
package Plugins::Blog;
use vars qw($VERSION @EXPORT @ISA);
use strict;

require Exporter;

$VERSION = 0.01;
@ISA = qw(Exporter);
@EXPORT = qw(blog);

sub blog {
   my $app = shift;

   if(!$app->{__PACKAGE__ . '__oBlog'}) {
      # create the object for this module and store it in the app
       my $blog = {};
       bless $blog;
       $app->{__PACKAGE__ . '__oBlog'} = $blog;
   }

   return $app->{__PACKAGE__ . '__oBlog'};
}
--- snip ---

Now - the question I have is (assuming cgiapp is the calling object) how do I in a different method retrieve the database handle? ie

--- snip ---
sub getBlog {
   # this is the object itself, not the cgiapp
   $self = shift;
   $dbh = $self->dbh; # ??? confused!
}
--- snip ---

Help would be much appreciated. I've tried this various ways (putting a reference to the app's dbh method in the object), but can't figure it out. I'm going wrong somewhere and have looked at other code, but can't quite figure it out.

Thanks in advance.

Paul


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
             http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to