perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Russell <...@onlywebdata.com>
Subject re: pnotes MP1->MP2
Date Mon, 03 Apr 2006 23:37:47 GMT
Thank you for your help, a workaround has been found.
The cause of failure seems to be using pnotes in a subroutine
called by the handler.

It is easy enough to work around the problem by avoiding the subroutine.
Forgive me if I've wasted the list's time with poor coding but perhaps
it is a bug. Here's how it can be reproduced if it might be a bug.


package Xdb::AuthOra2;

use strict;

use Apache2::Access ();

#use Apache2::Connection ();

#use Apache2::RequestUtil ();
use Apache2::Log;

# loaded by startup.pl
#use Apache2::RequestRec ();
#use Apache2::Const -compile => qw (OK DECLINED REDIRECT  
HTTP_UNAUTHORIZED);

sub handler {

#sub handler : method {
#  my $self = shift;
   my $q    = shift;

   # use a subroutine - causes pnotes to fail.
   # all in one method commented out.
   my $reason = authenticate($q);

   #my ($dbh, $reason);

   #unless($dbh = DBI->connect("dbi:Oracle:XE", "WEB_LOGIN", "nnnn",
   #            {RaiseError => 0, AutoCommit => 1, PrintError => 0})) {
   #         $reason = "Error connecting.\n$DBI::errstr\n";
   #}

   if ($reason) {
      $q->note_basic_auth_failure;
      $q->log_reason($reason, $q->filename);
      return Apache2::Const::HTTP_UNAUTHORIZED;
   }

   # performed in subroutine
   #$q->pnotes(DBH => $dbh);

   return Apache2::Const::OK;
}

sub authenticate {

   my $r    = shift;

   my $dbh;

   $dbh = DBI->connect("dbi:Oracle:XE", "WEB_LOGIN", "nnnn",
               {RaiseError => 0, AutoCommit => 1, PrintError => 0})
           || return "Error connecting.\n$DBI::errstr\n";
   }

   $r->pnotes(DBH => $dbh);
}


1;
__END__






On Apr 3, 2006, at 3:01 PM, Issac Goldstand wrote:

> It should work fine.  I wrote the same thing today (albeit without
> method calls)...
>
> # Trans handler
> sub lookup_handler {
>   my $r=shift;
>   my $dbh=GTS::Util::connectdb(); # essentially a wrapper for DBI- 
> >connect
>   ...
>   $r->pnotes(dbh=>$dbh);
>   return Apache2::Const::DECLINED;
> }
>
> # Response handler
> sub fullresponse_handler {
>   my $r=shift;
>   # Get direction from DB
>   my $dbh=$r->pnotes('dbh');
>   ...
> }
>
>   Issac
>
> John Russell wrote:
>> Thank you. Tried it, unfortunately no difference.
>> I'll try Geoffrey Young's test.
>>
>


Mime
View raw message