richter 00/08/15 22:34:58
Modified: . Embperl.pm TODO test.pl
Embperl Session.pm
test/conf httpd.conf.src
Log:
- Start for Apache::Session 1.5x Interface
Revision Changes Path
1.109 +22 -6 embperl/Embperl.pm
Index: Embperl.pm
===================================================================
RCS file: /home/cvs/embperl/Embperl.pm,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -r1.108 -r1.109
--- Embperl.pm 2000/07/17 05:16:03 1.108
+++ Embperl.pm 2000/08/16 05:34:56 1.109
@@ -10,7 +10,7 @@
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
-# $Id: Embperl.pm,v 1.108 2000/07/17 05:16:03 richter Exp $
+# $Id: Embperl.pm,v 1.109 2000/08/16 05:34:56 richter Exp $
#
###################################################################################
@@ -79,7 +79,7 @@
@ISA = qw(Exporter DynaLoader);
-$VERSION = '1.3b4';
+$VERSION = '1.3b5_dev';
# HTML::Embperl cannot be bootstrapped in nonlazy mode except
@@ -351,14 +351,16 @@
$SessionMgnt = 0 ;
if (defined ($ENV{EMBPERL_SESSION_CLASSES}))
{ # Apache::Session 1.xx
- my ($os, $lm) = split /\s*,\s*|\s+/, $ENV{EMBPERL_SESSION_CLASSES} ;
+ my ($os, $lm, $ser, $gen) = split /\s*,\s*|\s+/, $ENV{EMBPERL_SESSION_CLASSES} ;
if (!$os || !$lm)
{
warn "[$$]SES: EMBPERL_SESSION_CLASSES must be set properly (is
$ENV{EMBPERL_SESSION_CLASSES})" ;
}
else
{
- my @args ;
+ $ser ||= 'Storable' ;
+ $gen ||= 'MD5' ;
+ my @args ;
if (defined ($ENV{EMBPERL_SESSION_ARGS}))
{
my @arglist = split /\s+/, $ENV{EMBPERL_SESSION_ARGS} ;
@@ -374,9 +376,23 @@
@args,
lazy => 1,
create_unknown => 1,
- object_store => $os,
- lock_manager => $lm
) ;
+
+ my $ver ;
+ if ($Apache::Session::VERSION =~ /^1\.0\d$/)
+ {
+ $sargs{object_store} = $os ;
+ $sargs{lock_manager} = $lm ;
+ $ver = '1.0x' ;
+ }
+ else
+ { # Apache::Session >= 1.50
+ $sargs{Store} = $os ;
+ $sargs{Lock} = $lm ;
+ $sargs{Generate} = $gen ;
+ $sargs{Serialize} = $ser ;
+ $ver = '>= 1.50' ;
+ }
my $session_handler = $ENV{EMBPERL_SESSION_HANDLER_CLASS} ||
'HTML::Embperl::Session' ;
eval "require $session_handler" ;
@@ -385,7 +401,7 @@
tie %udat, $session_handler, undef, \%sargs ;
tie %mdat, $session_handler, undef, \%sargs ;
$SessionMgnt = 2 ;
- warn "[$$]SES: Embperl Session management enabled (1.xx)\n" if
($ENV{MOD_PERL}) ;
+ warn "[$$]SES: Embperl Session management enabled ($ver)\n" if
($ENV{MOD_PERL}) ;
}
}
elsif (exists $INC{'Apache/Session.pm'})
1.96 +2 -0 embperl/TODO
Index: TODO
===================================================================
RCS file: /home/cvs/embperl/TODO,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -r1.95 -r1.96
--- TODO 2000/08/10 19:32:46 1.95
+++ TODO 2000/08/16 05:34:56 1.96
@@ -68,6 +68,8 @@
- cookie form $req_rec [Jack Cushman 27.7.00]
+- Execute backtrace [Jon Brisbin 12.8.00]
+
Test
----
- test FORBIDDEN
1.63 +1 -1 embperl/test.pl
Index: test.pl
===================================================================
RCS file: /home/cvs/embperl/test.pl,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- test.pl 2000/07/17 05:16:09 1.62
+++ test.pl 2000/08/16 05:34:56 1.63
@@ -309,7 +309,7 @@
$EPPORT2 = ($EPPORT || 0) + 1 ;
-$EPSESSIONCLASS = $ENV{EMBPERL_SESSION_CLASS} || (($EPSESSIONVERSION =~
/^0\.17/)?'Win32':'0') || ($EPSESSIONVERSION > 1.00?'Embperl':'0') ;
+$EPSESSIONCLASS = $ENV{EMBPERL_SESSION_CLASS} || (($EPSESSIONVERSION =~
/^0\.17/)?'Win32':'0') || ($EPSESSIONVERSION >= 1.00?'Embperl':'0') ;
$EPSESSIONDS = $ENV{EMBPERL_SESSION_DS} || 'dbi:mysql:session' ;
die "You must install libwin32 first" if ($EPWIN32 && $win32loaderr && $EPHTTPD) ;
1.2 +159 -27 embperl/Embperl/Session.pm
Index: Session.pm
===================================================================
RCS file: /home/cvs/embperl/Embperl/Session.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Session.pm 1999/11/02 08:33:25 1.1
+++ Session.pm 2000/08/16 05:34:57 1.2
@@ -37,13 +37,34 @@
=item object_store
Specify the class for the object store. (The Apache::Session:: prefix is
-optional)
+optional) Only for Apache::Session 1.00.
=item lock_manager
Specify the class for the lock manager. (The Apache::Session:: prefix is
-optional)
+optional) Only for Apache::Session 1.00.
+=item Store
+
+Specify the class for the object store. (The Apache::Session::Store prefix is
+optional) Only for Apache::Session 1.5x.
+
+=item Lock
+
+Specify the class for the lock manager. (The Apache::Session::Lock prefix is
+optional) Only for Apache::Session 1.5x.
+
+=item Generate
+
+Specify the class for the id generator. (The Apache::Session::Generate prefix is
+optional) Only for Apache::Session 1.5x.
+
+=item Serialize
+
+Specify the class for the data serializer. (The Apache::Session::Serialize prefix is
+optional) Only for Apache::Session 1.5x.
+
+
=back
Example using attrubtes to specfiy store and object classes instead of
@@ -97,7 +118,7 @@
use strict;
use vars qw(@ISA $VERSION);
-$VERSION = '1.00';
+$VERSION = '1.50';
@ISA = qw(Apache::Session);
use Apache::Session;
@@ -114,11 +135,42 @@
my $session_id = shift;
my $args = shift || {};
- if(ref $args ne "HASH") {
+ if(ref $args ne "HASH")
+ {
die "Additional arguments should be in the form of a hash reference";
+ }
+
+ #Set-up the data structure and make it an object
+ #of our class
+
+ my $self =
+ {
+ args => $args,
+ data => { _session_id => $session_id },
+ lock => 0,
+ lock_manager => undef,
+ object_store => undef,
+ status => 0,
+ serialized => undef,
+ };
+
+ bless $self, $class;
+
+ $self -> require_modules ($args) ;
+
+ $self -> init if (!$args -> {'lazy'}) ;
+
+
+ return $self ;
}
+
+
+sub require_modules
+ {
+ my $self = shift ;
+ my $args = shift ;
- # check object_store and lock_manager classes
+ # check object_store and lock_manager classes (Apache::Session 1.00)
if ($args -> {'object_store'})
{
@@ -133,28 +185,42 @@
eval "require $args->{'lock_manager'}" ;
die "Cannot require $args->{'lock_manager'}" if ($@) ;
}
-
- #Set-up the data structure and make it an object
- #of our class
- my $self = {
- args => $args,
- data => { _session_id => $session_id },
- lock => 0,
- lock_manager => undef,
- object_store => undef,
- status => 0
- };
+ # check Store, Lock, Generate, Serialize classes (Apache::Session 1.5x)
- bless $self, $class;
+ if ($args -> {'Store'})
+ {
+ $args -> {'Store'} = "Apache::Session::Store::$args->{'Store'}" if (!($args
-> {'Store'} =~ /::/)) ;
+ eval "require $args->{'Store'}" ;
+ die "Cannot require $args->{'Store'}" if ($@) ;
+ }
- $self -> init if (!$args -> {'lazy'}) ;
+ if ($args -> {'Lock'})
+ {
+ $args -> {'Lock'} = "Apache::Session::Lock::$args->{'Lock'}" if (!($args ->
{'Lock'} =~ /::/)) ;
+ eval "require $args->{'Lock'}" ;
+ die "Cannot require $args->{'Lock'}" if ($@) ;
+ }
+ if ($args -> {'Generate'})
+ {
+ $args -> {'Generate'} = "Apache::Session::Generate::$args->{'Generate'}" if
(!($args -> {'Generate'} =~ /::/)) ;
+ eval "require $args->{'Generate'}" ;
+ die "Cannot require $args->{'Generate'}" if ($@) ;
+ }
- return $self ;
+ if ($args -> {'Serialize'})
+ {
+ $args -> {'Serialize'} = "Apache::Session::Serialize::$args->{'Serialize'}"
if (!($args -> {'Serialize'} =~ /::/)) ;
+ eval "require $args->{'Serialize'}" ;
+ die "Cannot require $args->{'Serialize'}" if ($@) ;
+ }
}
+
+
+
sub init
{
my $self = shift ;
@@ -164,7 +230,16 @@
my $session_id = $self->{data}->{_session_id} ;
- if (defined $session_id) {
+ $self->populate;
+
+ warn "s0 = $self->{data}->{_session_id}" ;
+ if (defined $session_id && $session_id)
+ {
+ if (exists $self -> {'args'}->{Transaction} && $self ->
{'args'}->{Transaction})
+ {
+ $self->acquire_write_lock;
+ }
+
$self->{status} &= ($self->{status} ^ NEW);
if ($self -> {'args'}{'create_unknown'})
@@ -176,17 +251,30 @@
{
$self->restore;
}
- }
+ }
+ warn "s00 = $self->{data}->{_session_id}" ;
if (!($self->{status} & SYNCED))
{
$self->{status} |= NEW();
- $self->{data}->{_session_id} = $self -> generate_id() if
(!$self->{data}->{_session_id}) ;
+ if (!$self->{data}->{_session_id})
+ {
+ if (exists ($self->{generate}))
+ { # Apache::Session >= 1.50
+ $self->{data}->{_session_id} = &{$self->{generate}}($self) ;
+ warn "s1 = $self->{data}->{_session_id}" ;
+ }
+ else
+ {
+ $self->{data}->{_session_id} = $self -> generate_id() if
(!$self->{data}->{_session_id}) ;
+ }
+ }
+ warn "s2 = $self->{data}->{_session_id}" ;
$self->save;
- }
+ }
return $self;
-}
+ }
sub FETCH {
my $self = shift;
@@ -267,12 +355,14 @@
$self->release_all_locks;
}
-sub cleanup {
+sub cleanup
+ {
my $self = shift;
if (!$self -> {'status'})
{
$self->{data} = {} ;
+ $self->{serialized} = undef ;
return ;
}
@@ -281,7 +371,8 @@
$self->{'status'} = 0 ;
$self->{data} = {} ;
-}
+ $self->{serialized} = undef ;
+ }
sub setid {
@@ -297,7 +388,22 @@
return $self->{data}->{_session_id} ;
}
+sub delete {
+ my $self = shift;
+
+ return if ($self->{status} & NEW);
+
+ $self -> init if (!$self -> {'status'}) ;
+ $self->{status} |= DELETED;
+ $self->save;
+}
+
+
+#
+# For Apache::Session 1.00
+#
+
sub get_object_store {
my $self = shift;
@@ -309,5 +415,31 @@
return new {$self -> {'args'}{'lock_manager'}} $self;
}
+
+
+#
+# For Apache::Session >= 1.50
+#
+
+sub populate
+ {
+ my $self = shift;
+
+ my $store = $self->{args}->{Store};
+ my $lock = $self->{args}->{Lock};
+ my $gen = $self->{args}->{Generate};
+ my $ser = $self->{args}->{Serialize};
+
+
+ $self->{object_store} = new $store $self if ($store) ;
+ $self->{lock_manager} = new $lock $self if ($lock);
+ $self->{generate} = \&{$gen . '::generate'} if ($gen);
+ $self->{serialize} = \&{$ser . '::serialize'} if ($ser);
+ $self->{unserialize} = \&{$ser . '::unserialize'} if ($ser) ;
+
+ return $self;
+ }
+
+
-1
+1 ;
1.22 +14 -1 embperl/test/conf/httpd.conf.src
Index: httpd.conf.src
===================================================================
RCS file: /home/cvs/embperl/test/conf/httpd.conf.src,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- httpd.conf.src 2000/07/17 05:16:25 1.21
+++ httpd.conf.src 2000/08/16 05:34:58 1.22
@@ -59,7 +59,7 @@
EOD
}
-if ($EPSESSIONVERSION && $EPSESSIONVERSION >= 1)
+if ($EPSESSIONVERSION && ($EPSESSIONVERSION =~ /^1\.0\d$/))
{
print OFH <<EOD ;
@@ -69,6 +69,19 @@
SetEnv EMBPERL_SESSION_ARGS "Directory=$EPPATH/test/tmp"
EOD
}
+elsif ($EPSESSIONVERSION && ($EPSESSIONVERSION > 1))
+ {
+print OFH <<EOD ;
+
+PerlSetEnv EMBPERL_SESSION_CLASSES "File Null"
+PerlSetEnv EMBPERL_SESSION_ARGS "Directory=$EPPATH/test/tmp"
+SetEnv EMBPERL_SESSION_CLASSES "File Null"
+SetEnv EMBPERL_SESSION_ARGS "Directory=$EPPATH/test/tmp"
+EOD
+ }
+
+
+
print OFH <<EOD ;
SetEnv EMBPERL_ALLOW asc|\\.htm\$
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]