mod_perl && php && apache || !

2002-12-24 Thread Joseph P. Crotty
Recently I gave php a go.  While playing with it I was unable to find any 
documentation pertaining to how it interacts with apache
(e.g. php provides some nice session functions and cookie handling, but doesn't 
explain at exactly which phases of the apache
request loop it's interacting with apache, in this sense it is more of a pure 
abstraction then mod_perl).

I don't' want to discuss the merits of php vs. mod_perl!

Would it be reasonable to set up apache with both mod_perl and php and use php mostly 
for the sake of embedding say database data
and then writing mod_perl handlers for the rest, or is this recipe fraught with 
disaster??

Joe Crotty





Apache::SessionManager pnotes index.html problem...

2003-01-22 Thread Joseph P. Crotty
Here is the simplest form of the problem I can produce.

I have two handlers and want to pass some info between them visa vi pnotes.  One
is a PerlTransHandler for Apache::SessionManager and the other is a PerlHandler
for a simple Hello.pm that dumps some html with the current _session_start value
(i.e. from pnotes).  Apache::SessionManager checks to see if a session file
exists, creates one if not, and updates pnotes appropriately.

The problem - if I request index.html there is no value in pnotes for
_session_start as confirmed by Hello.pm.  It seems that there is nothing in
pnotes period.  If after the request I manually inspect the session file created
I find a value for _session_start.  Request other pages (e.g. test.html) and
there are expected pnotes entries confirmed by Hello.pm.

Apache 1.3.27 mod_perl


#START mod_perl Configuration
#
PerlRequire conf/startup.pl
PerlSetEnv  MOD_PERL_TRACE all

PerlSetEnv  SERVER_ROOT /usr/local/apache/
#--
#END mod_perl Configuration


#START Apache::SessionManager Configuration
#--
PerlModule Apache::SessionManager
PerlTransHandler Apache::SessionManager
#
#END Apache::SessionManager Configuration


#START Block Directives
#--

SetHandler perl-script
PerlSetVar SessionManagerDebug 0
PerlSetVar SessionManagerTracking On
PerlSetVar SessionManagerExpire 3600
PerlSetVar SessionManagerStore File
PerlSetVar SessionManagerStoreArgs "Directory =>
/usr/local/apache/session, \
LockDirectory =>
/usr/local/apache/session/lock"




SetHandler perl-script
PerlHandler MyApache::Hello



SetHandler perl-script
PerlHandler MyApache::Hello



Alias /perl/ "/usr/local/apache/perl/"


AllowOverride  None
Options+ExecCGI
SetHandler perl-script
PerlHandlerApache::Registry
PerlSendHeader On

#
#END Block Directives



package MyApache::Hello;

use strict;
use Apache::Constants qw(:common);

sub handler {
my $r = shift;
$r->content_type('text/html');
$r->send_http_header;

my $host = $r->get_remote_host;
my $href_session = $r->pnotes('SESSION_MANAGER_HANDLE');
unless ($href_session) {
print STDERR "nada\n";
}
my $sess_start = $href_session->{'_session_start'};
$r->print(<

Hello There


Hello $host
Sessoin Start: $sess_start


END

return OK;
}
1;