Andy, Thank you for your help. Gerald's comment about SetupSession passing a hash ref and not a hash primarily resolved my problem!
I am curious though. I have experimented with the Apache::is_main() function over the last few days, and can't quite figure it out. I would have presumed that this would indicate a direct GET/POST request as opposed to a sub-request being a URI embedded within the resultant page. This does not appear so, and I get for example, <IMG> tags embedded in a page being designated as main requests. Would anybody care to elucidate on these definitions? Also, I too have experienced indeterminate problems with Postgres connections. I use Apache::DBI and set up a single DBI_DSN environment which will default to all DBI and DBIx::Recordset connections. With this arrangement, I expect a single connection per Apache process - for the life of that process. I do note in my embperl logs though many DB disconnect then connect operations. I am also getting my browser/Apache spinning at a download rate of a few bytes/sec, which I am strongly suspicious is a result of a lost DB connection for the Apache process and it's subsequent inability to continue streaming the rest of the page. Are there any implications of using Apache::DBI for Perl*Handler's other than PerlHandler? (not that I can see why as it's a BEGIN block isn't it ...) Below is a small section from my embperl log showing database connection activity. If anyone else has experienced such problems, I'd be interested to hear. Cheers, Alan [14539]SES: Received session cookie 0641f8216009661f4c64ef144c45b030 DB: Disconnect (id=4, numOpen = 1) [14539]Formdata... length = 0 [14539]Using APACHE for output... [14539]CACHE: SvTYPE (*ppSV) = 7 [14539]CACHE: SvTYPE (*ppSV) = 12 [14539]CACHE: SvTYPE (*ppSV) = 7 [14539]CACHE: SvTYPE (*ppSV) = 12 [14539]EVAL< <unknown> DB: Successfull connect to (id=5, numOpen = 2) DB: 'SELECT * FROM menuitem, groupname_file WHERE (menuitem.file = groupname_file.file) and ( ( (gro >From: Andrew O'Brien <[EMAIL PROTECTED]> >To: alan milligan <[EMAIL PROTECTED]> >Subject: Re: Perl*Handlers and Embperl Sessions >Date: Mon, 29 Oct 2001 18:19:32 +1100 >MIME-Version: 1.0 >Received: from [202.7.89.204] by hotmail.com (3.2) with ESMTP id >MHotMailBDA64E06000A4004319BCA0759CCFAE60; Sun, 28 Oct 2001 23:19:35 -0800 >Received: from phoenix.switchonline.com.au (phoenix.switchonline.com.au >[192.168.1.20])by beast.switchonline.com.au (Postfix) with ESMTP id >9357217Bfor <[EMAIL PROTECTED]>; Mon, 29 Oct 2001 18:19:33 +1100 >(EST) >Received: from andrewo by phoenix.switchonline.com.au with local (Exim 3.32 >#1 (Debian))id 15y6ho-0003DN-00for <[EMAIL PROTECTED]>; Mon, 29 Oct >2001 18:19:32 +1100 >From [EMAIL PROTECTED] Sun, 28 Oct 2001 23:20:50 -0800 >Message-ID: <[EMAIL PROTECTED]> >References: <[EMAIL PROTECTED]> >In-Reply-To: <[EMAIL PROTECTED]> >User-Agent: Mutt/1.3.22i > >On Mon, Oct 29, 2001 at 05:43:45AM +0000, alan milligan wrote: > > Hi, > > > > I am attempting to write a mod_perl handler to get invoked before the > > PerlHandler which is HTML::Embperl. > > > > One of my Embperl scripts sets up a 'user' object in %udat which needs >to be > > retrieved and authenticated in the PerlAuthzHandler of each request. > >I'm not sure how useful this answer is but I'm throwing it out into >the aether just in case. > >I wrote a simple AccessHandler that checked login status via %udat >variables which is more or less the same thing. There were some >strange things happening with session database locking at one point >and I did notice some weirdness with %udat but this works for >me(tm). I'll add some working (at least here) code to your handler() >function. > >It may work just coz I ignore the problem tho. Big fat hack at the >FIXME FIXME line :) > >I hit this %udat thing and I can't remember what was causing it, sorry >:( Fixing issues with postgres session locking to allow things to >actually work at all was our first priority. There are comments in the >code below for what little its worth. > >[snip] > > sub handler { > > > > my $req_rec = shift; > > > > $req_rec->warn("Balclutha::mod_auth doing: " . $req_rec->uri); > > >+ # don't know if you do want to be authenticating for subrequests >+ # but if not: >+ return DECLINED unless $req_rec->is_main(); > > > > #print STDERR "HTML::Embperl is: ", Dumper(%HTML::Embperl::), "\n"; > > # > > # DECLINED is passthru ... > > # > > return DECLINED if defined $OK_URLS{$req_rec->uri}; > > > > my %rec; > > # > > # setup %ENV > > # > > HTML::Embperl::ScanEnvironment(\%rec, $req_rec); >+ # Why is this here? I don't see you using %rec later on .... > > >- HTML::Embperl::Req::SetupSession($req_rec); >- my %udat = HTML::Embperl::Req::GetSession; >+ # get udat from Embperl's SetupSession >+ my $udat = HTML::Embperl::Req::SetupSession($req_rec); >+ >+ # FIXME: This should be a DB error page if sessions aren't >+ # working. ie $udat == undef >+ # FIXME FIXME: How the hell can we get here if the session db is up >+ # need to investigate this. Check Embperl execution codepath. This is >+ # why its not FORBIDDEN atm. >+ return DECLINED unless $udat; >+ #return FORBIDDEN unless $udat; > > > > if (exists $udat{user}) { >[check stuff] > > } > > >+ # since we setup a session, register to setdown it, just in case >+ # this isn't an Embperl page we're visiting :) >+ $req_rec->register_cleanup(\&HTML::Embperl::Req::CleanupSession); > > # > > # maybe it's one of the 'defaults' available to all users ... > > # > > my $server_protocol = 'http'; > > $server_protocol = 'https' if exists $ENV{HTTPS}; > > > > *set = DBIx::Recordset->Search({'!Table' => 'groupname_file', > > '$where' => 'groupname = ? and file = ?', > > '$values' => [ $server_protocol, $req_rec->uri ] >}) ; > > > > my $rec = $set->Next; > > return DECLINED if $rec; # found it ... > > > > # > > # don't know this user, no record of the file either -> sod off > > # > > $req_rec->log_error("Balclutha::mod_auth failed auth, no user and no > > entry in groupname_file: " . $req_rec->uri); > > return 403; > > } > > > > 1; > > > > __END__ > >-- > Andrew O'Brien > Product Engineer email: >[EMAIL PROTECTED] > Switch Online Group Pty Limited phone: +61 2 9299 1133 > ABN 89 092 286 327 fax: +61 2 9299 1134 _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]