MasonX-Request-WithApacheSession-0.31/ 0000755 0035230 0036653 00000000000 10732320531 020567 5 ustar lhotskyb Domain Users MasonX-Request-WithApacheSession-0.31/Build.PL 0000444 0035230 0036653 00000006360 10732320526 022072 0 ustar lhotskyb Domain Users use strict;
use Cwd;
use File::Basename;
use File::Spec;
use Module::Build;
my $build =
Module::Build->new( module_name => 'MasonX::Request::WithApacheSession',
license => 'perl',
requires => { 'HTML::Mason' => '1.16',
'Apache::Session::Wrapper' => '0.13',
},
sign => 1,
create_makefile_pl => 'passthrough',
);
# only bother with this stuff for the maintainer
if ( -d '.svn' )
{
use lib 't/lib';
require Apache::test;
my %p = Apache::test->get_test_params();
if (%p)
{
my $cwd = cwd();
my $conf_file = File::Spec->catfile( $cwd, 't', 'httpd.conf' );
my $apache_dir = dirname($conf_file);
$apache_dir =~ s,/$,,;
my $comp_root = File::Spec->catdir( $apache_dir, 'comps' );
my $data_dir = File::Spec->catdir( $apache_dir, 'data' );
unless ( -d $comp_root )
{
mkdir $comp_root, 0755
or die "Can't make dir '$comp_root': $!";
}
unless ( -d $data_dir )
{
mkdir $data_dir, 0755
or die "Can't make dir '$data_dir': $!";
}
my $session_dir =
File::Spec->catdir( File::Spec->tmpdir, 'sessions' );
unless ( -d $session_dir )
{
mkdir $session_dir, 0755
or die "Can't make dir '$session_dir': $!";
}
my $base_config = <<"EOF";
PerlSetVar MasonSessionClass Apache::Session::File
PerlSetVar MasonSessionDirectory $session_dir
PerlSetVar MasonSessionLockDirectory $session_dir
PerlSetVar MasonCompRoot $comp_root
PerlSetVar MasonDataDir $data_dir
SetHandler perl-script
PerlHandler HTML::Mason::ApacheHandler
EOF
my $include = <<"EOF";
PerlSetVar MasonRequestClass MasonX::Request::WithApacheSession
PerlSetVar MasonSessionUseCookie 1
$base_config
PerlSetVar MasonRequestClass MasonX::Request::WithApacheSession
PerlSetVar MasonSessionUseCookie 1
PerlSetVar MasonSessionCookieResend 0
$base_config
PerlSetVar MasonRequestClass MasonX::Request::WithApacheSession
PerlSetVar MasonSessionUseCookie 0
$base_config
PerlSetVar MasonRequestClass MasonX::Request::WithApacheSession
PerlSetVar MasonSessionUseCookie 1
PerlSetVar MasonSessionCookieExpires session
$base_config
PerlSetVar MasonRequestClass MasonX::Request::WithApacheSession
PerlSetVar MasonSessionUseCookie 1
PerlSetVar MasonSessionArgsParam SID
$base_config
EOF
local $^W;
Apache::test->write_httpd_conf
( %p,
include => $include
);
$build->add_to_cleanup( map { "$apache_dir/$_" }
qw( httpd.conf error_log httpd httpd.pid )
);
$build->add_to_cleanup( $comp_root, $data_dir, $session_dir );
}
}
$build->create_build_script;
MasonX-Request-WithApacheSession-0.31/README 0000444 0035230 0036653 00000002114 10732320526 021447 0 ustar lhotskyb Domain Users HTML::Mason::Request::WithApacheSession
=======================================
This module takes advantage of the new flexibility in Mason 1.09_01
and newer to integrate an Apache::Session session directly into
Mason's Request object.
This module is very alpha at this point, considering that it only
works with a beta release of Mason!
INSTALLATION
To install this module type the following:
perl Makefile.PL
make
make test
make install
Then in your httpd.conf file add:
PerlSetVar MasonRequestClass HTML::Mason::Request::WithApacheSession
PerlSetVar MasonSessionClass Apache::Session::File
PerlSetVar MasonSessionDataSource dbi:mysql:somedb
DEPENDENCIES
You must have Mason 1.10 or newer installed for this module to work
at all.
BUGS
Bug reports should be sent to the mason-users list. See
http://www.masonhq.com/resources/mailing_lists.html for more details.
COPYRIGHT AND LICENCE
Copyright (c) 2002 David Rolsky
All rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
MasonX-Request-WithApacheSession-0.31/lib/ 0000755 0035230 0036653 00000000000 10732320526 021341 5 ustar lhotskyb Domain Users MasonX-Request-WithApacheSession-0.31/lib/MasonX/ 0000755 0035230 0036653 00000000000 10732320526 022546 5 ustar lhotskyb Domain Users MasonX-Request-WithApacheSession-0.31/lib/MasonX/Request/ 0000755 0035230 0036653 00000000000 10732320526 024176 5 ustar lhotskyb Domain Users MasonX-Request-WithApacheSession-0.31/lib/MasonX/Request/WithMultiSession.pm 0000444 0035230 0036653 00000016630 10732320526 030032 0 ustar lhotskyb Domain Users package MasonX::Request::WithMultiSession;
use strict;
use Digest::SHA1 ();
use Time::HiRes;
use base qw(MasonX::Request::WithApacheSession);
use HTML::Mason::Exceptions ( abbr => [ qw( param_error error ) ] );
use Params::Validate qw( validate SCALAR );
Params::Validate::validation_options( on_fail => sub { param_error( join '', @_ ) } );
__PACKAGE__->valid_params
( multi_session_args_param =>
{ type => SCALAR,
default => 'sub_session_id',
descr => 'The parameter name which contains the sub-session id',
},
multi_session_expire =>
{ type => Params::Validate::SCALAR,
default => undef,
descr => 'How long a sub-session stays valid',
},
);
sub session
{
my $self = shift;
return $self->parent_request->session(@_) if $self->is_subrequest;
my %p = @_;
my %super_p = exists $p{session_id} ? ( session_id => $p{session_id} ) : ();
my $session = $self->SUPER::session(%super_p);
my %sub_session_p =
exists $p{sub_session_id} ? ( sub_session_id => $p{sub_session_id} ) : ();
my $id = $self->sub_session_id(%sub_session_p);
if ( $p{clone} || $p{new} )
{
# forces creation of a new id
delete $self->{sub_session_id};
my $new_id = $self->_make_new_sub_session_id;
if ( $p{clone} )
{
# shallow copy of old session
$session->{sub_sessions}{$new_id} = { %{ $session->{sub_sessions}{$id} } };
}
$id = $new_id;
}
$session->{sub_session_ids}{$id} = int(time);
return $session->{sub_sessions}{$id};
}
sub sub_session_id
{
my $self = shift;
my %p = validate( @_,
{ sub_session_id =>
{ type => SCALAR,
optional => 1,
},
} );
unless ( exists $self->{sub_session_id} )
{
my $args = $self->request_args;
my $args_key = $self->{multi_session_args_param};
my $session = $self->SUPER::session;
if ( exists $p{sub_session_id} )
{
unless ( exists $session->{sub_session_ids}{ $p{sub_session_id} } )
{
$session->{sub_sessions}{ $p{sub_session_id} } = {};
}
$self->{sub_session_id} = $p{sub_session_id};
}
elsif ( exists $args->{$args_key} &&
exists $session->{sub_session_ids}{ $args->{$args_key} } )
{
$self->{sub_session_id} = $args->{$args_key};
}
else
{
$self->_make_new_sub_session_id;
}
}
return $self->{sub_session_id};
}
sub _make_new_sub_session_id
{
my $self = shift;
my $session = $self->SUPER::session;
my $new_id;
do
{
# using Time::HiRes means that we get times with very high
# floating point resolutions (to 10 or 11 decimal places), so
# this is a good seed for a hashing algorithm
$new_id = Digest::SHA1::sha1_hex( time() . {} . rand() . $$ );
} while ( exists $session->{sub_session_ids}{$new_id} );
$session->{sub_sessions}{$new_id} = {};
$self->{sub_session_id} = $new_id;
return $new_id;
}
sub delete_sub_session
{
my $self = shift;
my $session = $self->SUPER::session;
my %p = validate( @_,
{ sub_session_id =>
{ type => SCALAR,
optional => 1,
},
} );
my $sub_id = $p{sub_session_id} ? $p{sub_session_id} : delete $self->{sub_session_id};
delete $session->{sub_sessions}{$sub_id};
delete $session->{sub_session_ids}{$sub_id};
}
sub delete_session
{
my $self = shift;
$self->SUPER::delete_session;
delete $self->{sub_session_id};
}
sub DESTROY
{
my $self = shift;
return unless defined $self->{multi_session_expire};
my $session = $self->SUPER::session;
my $cutoff = int(time) - $self->{multi_session_expire};
foreach my $id ( keys %{ $session->{sub_session_ids} } )
{
if ( $session->{sub_session_ids}{$id} < $cutoff )
{
delete $session->{sub_sessions}{$id};
delete $session->{sub_session_ids}{$id};
}
}
}
1;
__END__
=head1 NAME
MasonX::Request::WithMultiSession - Multiple sub-sessions within one "parent" session
=head1 SYNOPSIS
PerlSetVar MasonRequestClass MasonX::Request::WithMultiSession
=head1 DESCRIPTION
This module subclasses C in order
to allow multiple "sub-sessions" to exist within one parent session.
This can be quite useful for a web app where you want to allow the
user to open multiple windows, each with a different session, but
session ids are stored in a cookie.
Like C, sub-sessions are shared
between a request and any subrequests it creates.
=head1 METHODS
This class has an interface quite similar to that of
C.
=over 4
=item * session
The primary interface to this class is through the C
method. When this method is called without any parameters, the module
looks for an existing sub-session specified by the sub-session id
argument parameter (which can be in a query string or POST). This
value can be overridden by explicitly passing a "sub_session_id"
parameter.
If this parameter is found, an existing sub-session is returned. If
this parameter is not found, a new sub-session is created.
If the C method is called as C<< session( clone => 1 ) >>
then a new sub-session will be created, and its contents will be the
same as that of the current sub-session. This is a shallow copy of
the old session hash, so objects and references are shared between
them.
If C<< session( new => 1 ) >> is called, then a new, empty,
sub-session is created.
You can specify the main session id to use via the "session_id"
parameter.
=item * sub_session_id
This method returns the currently active sub-session's id. Use this
method to put this id into URL parameters, forms, etc. as needed.
If given a "sub_session_id" parameter, it will set the current
sub-session id.
=item * delete_sub_session
By default, this simply defaults the current sub-session. You can
pass a "sub_session_id" parameter to delete a specific session.
=back
=head2 Parameters
This module takes two parameters besides those inherited from
C:
=over 4
=item * multi_session_args_param / MultiSessionArgsParam
This parameter can be used to specify which parameter contains the
sub-session id. By default, the module will look for a parameter
called "sub_session_id".
=item * multi_session_expire / MultiSessionExpire
This parameter specifies the number of seconds after a sub-session is
accessed until it is purged. If not specified, then sub-sessions are
never purged.
Sub-sessions expiration is checked when the request object goes out of
scope.
=back
=head1 USAGE
You will need to manually set the sub-session id argument parameter
for each request. The easiest way to do this is to make sure that all
URLs contain the sub-session id. This can be done by using a C<<
<%filter> >> block in a top-level autohandler (although this won't
catch redirects), or by making sure all URLs are generated by a single
component/function.
=head1 SUPPORT
Bug reports and requests for help should be sent to the mason-users
list. See http://www.masonhq.com/resources/mailing_lists.html for
more details.
=head1 AUTHOR
Dave Rolsky,
Development funded by Marigold Technologies.
=head1 SEE ALSO
HTML::Mason
=cut
MasonX-Request-WithApacheSession-0.31/lib/MasonX/Request/WithApacheSession.pm 0000444 0035230 0036653 00000016551 10732320526 030123 0 ustar lhotskyb Domain Users package MasonX::Request::WithApacheSession;
use 5.005;
use strict;
use vars qw($VERSION @ISA);
$VERSION = '0.31';
use Apache::Session::Wrapper 0.13;
use HTML::Mason 1.16;
use HTML::Mason::Exceptions ( abbr => [ qw( param_error error ) ] );
use HTML::Mason::Request;
use Params::Validate qw(:all);
Params::Validate::validation_options( on_fail => sub { param_error( join '', @_ ) } );
# This may change later
@ISA = qw(HTML::Mason::Request);
#
# This is a bit of a hack, ideally we could do this:
#
# __PACKAGE__->contained_objects( class => 'Apache::Session::Wrapper',
# prefix => 'session_',
# );
#
# and let Class::Container sort it all out. We'd also need a way to
# override some of the contained class's defaults.
#
my $wrapper_p = Apache::Session::Wrapper->valid_params;
{
my %p = map { ( "session_$_" => $wrapper_p->{$_} ) } keys %$wrapper_p;
foreach my $k ( grep { exists $p{$_}{depends} } keys %p )
{
my %new = %{ $p{$k} };
my @d = ref $new{depends} ? @{ $new{depends} } : $new{depends};
$new{depends} = [ map { ( "session_$_" ) } @d ];
$p{$k} = \%new;
}
$p{session_cookie_name}{default} = 'MasonX-Request-WithApacheSession-cookie';
# We'll always provide this, so the user doesn't need to.
delete $p{session_param_name}{depends};
__PACKAGE__->valid_params
( # This is for backwards compatibility, it's been renamed to
# param_name
session_args_param =>
{ type => SCALAR,
optional => 1,
descr => 'Name of the parameter to use for session tracking',
},
%p,
);
}
sub new
{
my $class = shift;
$class->alter_superclass( $HTML::Mason::ApacheHandler::VERSION ?
'HTML::Mason::Request::ApacheHandler' :
$HTML::Mason::CGIHandler::VERSION ?
'HTML::Mason::Request::CGI' :
'HTML::Mason::Request' );
my $self = $class->SUPER::new(@_);
return $self if $self->is_subrequest;
# backwards compatibility
$self->{session_param_name} =
$self->{session_args_param} if exists $self->{session_args_param};
my %extra;
if ( $self->can('apache_req') )
{
%extra = ( header_object => $self->apache_req,
param_object => $self->apache_req,
);
}
elsif ( $self->can('cgi_process') )
{
%extra = ( header_object => $self->cgi_request,
param_object => $self->cgi_object,
);
}
$self->{apache_session_wrapper} =
Apache::Session::Wrapper->new
( %extra,
map { $_ => $self->{"session_$_"} }
grep { exists $self->{"session_$_"} }
keys %$wrapper_p
);
return $self;
}
sub wrapper
{
$_[0]->is_subrequest
? $_[0]->parent_request->wrapper
: $_[0]->{apache_session_wrapper}
}
sub exec
{
my $self = shift;
return $self->SUPER::exec(@_)
if $self->is_subrequest;
my @r;
if (wantarray)
{
@r = $self->SUPER::exec(@_);
}
else
{
$r[0] = $self->SUPER::exec(@_);
}
$self->wrapper->cleanup_session;
return wantarray ? @r : $r[0];
}
BEGIN
{
foreach my $meth ( qw( session delete_session ) )
{
no strict 'refs';
*{$meth} = sub { shift->wrapper->$meth(@_) };
}
}
1;
__END__
=head1 NAME
MasonX::Request::WithApacheSession - Add a session to the Mason Request object
=head1 SYNOPSIS
In your F file:
PerlSetVar MasonRequestClass MasonX::Request::WithApacheSession
PerlSetVar MasonSessionCookieDomain .example.com
PerlSetVar MasonSessionClass Apache::Session::File
PerlSetVar MasonSessionDirectory /tmp/sessions/data
PerlSetVar MasonSessionLockDirectory /tmp/sessions/locks
Or when creating an ApacheHandler object:
my $ah =
HTML::Mason::ApacheHandler->new
( request_class => 'MasonX::Request::WithApacheSession',
session_cookie_domain => '.example.com',
session_class => 'Apache::Session::File',
session_directory => '/tmp/sessions/data',
session_lock_directory => '/tmp/sessions/locks',
);
In a component:
$m->session->{foo} = 1;
if ( $m->session->{bar}{baz} > 1 ) { ... }
=head1 DESCRIPTION
This module integrates C into Mason by adding methods
to the Mason Request object available in all Mason components.
Any subrequests created by a request share the same session.
=head1 USAGE
To use this module you need to tell Mason to use this class for
requests. This can be done in one of two ways. If you are
configuring Mason via your F file, simply add this:
PerlSetVar MasonRequestClass MasonX::Request::WithApacheSession
If you are using a F file, simply add this parameter to
the parameters given to the ApacheHandler constructor:
request_class => 'MasonX::Request::WithApacheSession'
=head1 METHODS
This class adds two methods to the Request object.
=over 4
=item * session
This method returns a hash tied to the C class.
=item * delete_session
This method deletes the existing session from persistent storage. If
you are using the built-in cookie mechanism, it also deletes the
cookie in the browser.
=back
=head1 CONFIGURATION
This module accepts quite a number of parameters, most of which are
simply passed through to C. For this
reason, you are advised to familiarize yourself with the
C documentation before attempting to
configure this module.
If you are creating your own Interp/ApacheHandler/CGIHandler object in
a script or module, you should pass this object the parameters
intended for C, prefixed with "session_".
So to set the "class" parameter for C, you
pass in a "session_class" parameter.
If you are configuring Mason via your F file, you should
pass the "StudlyCaps" version of the name, prefixed by "MasonSession".
So the "class" parameter would be "MasonSessionClass".
A few examples:
=over 4
=item * class becomes session_class / MasonSessionClass
=item * always_write becomes session_always_write / MasonSessionAlwaysWrite
=back
When running under ApacheHandler or CGIHandler, this module takes care
of passing the "header_object" and "param_object" parameters to
C. These will be the C or
C objects, as applicable.
The "cookie_name" parameter defaults to
"MasonX-Request-WithApacheSession-cookie" when you use this module,
instead of "Apache-Session-Wrapper-cookie".
Finally, for backwards compatiblity, this module accepts a
"session_args_param" parameter, which corresponds to the "param_name"
parameter for C.
=head1 SUPPORT
As can be seen by the number of parameters above, C
has B too many possibilities for me to test all of them. This
means there are almost certainly bugs.
Bug reports and requests for help should be sent to the mason-users
list. See http://www.masonhq.com/resources/mailing_lists.html for
more details.
=head1 AUTHOR
Dave Rolsky,
=head1 MAINTAINER
Brad Lhotsky,
=head1 SEE ALSO
HTML::Mason
=cut
MasonX-Request-WithApacheSession-0.31/META.yml 0000444 0035230 0036653 00000001152 10732320526 022041 0 ustar lhotskyb Domain Users ---
name: MasonX-Request-WithApacheSession
version: 0.31
author:
- 'Dave Rolsky, '
abstract: Add a session to the Mason Request object
license: perl
resources:
license: http://dev.perl.org/licenses/
requires:
Apache::Session::Wrapper: 0.13
HTML::Mason: 1.16
provides:
MasonX::Request::WithApacheSession:
file: lib/MasonX/Request/WithApacheSession.pm
version: 0.31
MasonX::Request::WithMultiSession:
file: lib/MasonX/Request/WithMultiSession.pm
generated_by: Module::Build version 0.2808
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.2.html
version: 1.2
MasonX-Request-WithApacheSession-0.31/t/ 0000755 0035230 0036653 00000000000 10732320526 021036 5 ustar lhotskyb Domain Users MasonX-Request-WithApacheSession-0.31/t/03-multi.t 0000444 0035230 0036653 00000010575 10732320526 022603 0 ustar lhotskyb Domain Users #!/usr/bin/perl -w
use strict;
use File::Path;
use File::Spec;
use HTML::Mason::Tests;
my $tests = make_tests();
$tests->run;
sub make_tests
{
my $group =
HTML::Mason::Tests->new
( name => 'basic-session',
description => 'Basic tests for Request::WithMultiSession subclass',
pre_test_cleanup => 0,
);
my %params =
( request_class => 'MasonX::Request::WithMultiSession',
session_class => 'Flex',
session_store => 'File',
session_lock => 'Null',
session_generate => 'MD5',
session_serialize => 'Storable',
);
foreach ( [ session_directory => 'sessions' ],
)
{
my $dir = File::Spec->catfile( $group->data_dir, $_->[1] );
mkpath($dir);
$params{ $_->[0] } = $dir;
}
# will be used below in various ways
use Apache::Session::Flex;
my %session;
tie %session, 'Apache::Session::Flex', undef,
{ Store => 'File',
Lock => 'Null',
Generate => 'MD5',
Serialize => 'Storable',
Directory => $params{session_directory},
};
$session{bar}{baz} = 1;
my $id = $session{_session_id};
untie %session;
#------------------------------------------------------------
$group->add_test
( name => 'can_session',
description => 'make sure request->can("session")',
interp_params => \%params,
component => <<'EOF',
I <% $m->can('session') ? 'can' : 'cannot' %> session
EOF
expect => <<'EOF',
I can session
EOF
);
#------------------------------------------------------------
$group->add_test
( name => 'session_store',
description => 'store something in the session',
interp_params => \%params,
component => <<"EOF",
stored
<%init>
\$m->session( session_id => '$id', sub_session_id => '12345' )->{foo} = 'bar';
%init>
EOF
expect => <<'EOF',
stored
EOF
);
#------------------------------------------------------------
$group->add_test
( name => 'session_read',
description => 'read stored data from the session',
interp_params => \%params,
component => <<"EOF",
read: <% \$m->session( session_id => '$id', sub_session_id => '12345' )->{foo} %>
EOF
expect => <<'EOF',
read: bar
EOF
);
#------------------------------------------------------------
$group->add_support( path => '/as/subrequest',
component => <<'EOF',
foo: <% $m->session->{foo} %>
EOF
);
#------------------------------------------------------------
$group->add_test( name => 'subrequest1',
description => 'Make sure session is shared with subrequests',
interp_params => \%params,
component => <<'EOF',
Parent
% $m->session->{foo} = 'bar';
% $m->subexec( '/basic-session/as/subrequest' );
EOF
expect => <<'EOF',
Parent
foo: bar
EOF
);
#------------------------------------------------------------
$group->add_test
( name => 'delete_sub_session',
description => 'make sure delete_sub_session method works',
interp_params => \%params,
component => <<'EOF',
% $m->session->{foo} = 'foo';
<% $m->session->{foo} %>
% $m->delete_sub_session;
foo does <% exists $m->session->{foo} ? '' : 'not' %> exist
EOF
expect => <<'EOF',
foo
foo does not exist
EOF
);
#------------------------------------------------------------
$group->add_test
( name => 'delete_other_sub_session',
description => 'make sure delete_sub_session method can delete sub-session besides current one',
interp_params => \%params,
component => <<'EOF',
% $m->session->{foo} = 'foo';
<% $m->session->{foo} %>
% my $sub_id = $m->sub_session_id;
% $m->session( clone => 1 );
% $m->delete_sub_session( sub_session_id => $sub_id );
foo does <% exists $m->session->{foo} ? '' : 'not' %> exist
EOF
expect => <<'EOF',
foo
foo does exist
EOF
);
#------------------------------------------------------------
$group->add_test
( name => 'delete_session',
description => 'make sure delete_session method works with subclass',
interp_params => \%params,
component => <<'EOF',
% $m->session->{foo} = 'foo';
<% $m->session->{foo} %>
% $m->delete_session;
foo does <% exists $m->session->{foo} ? '' : 'not' %> exist
EOF
expect => <<'EOF',
foo
foo does not exist
EOF
);
#------------------------------------------------------------
return $group;
}
MasonX-Request-WithApacheSession-0.31/t/01-basic.t 0000444 0035230 0036653 00000013756 10732320526 022534 0 ustar lhotskyb Domain Users #!/usr/bin/perl -w
use strict;
use File::Path;
use File::Spec;
use HTML::Mason::Tests;
my $tests = make_tests();
$tests->run;
sub make_tests
{
my $group =
HTML::Mason::Tests->new
( name => 'basic-session',
description => 'Basic tests for Request::WithApacheSession subclass',
pre_test_cleanup => 0,
);
my %params =
( request_class => 'MasonX::Request::WithApacheSession',
session_class => 'Flex',
session_store => 'File',
session_lock => 'Null',
session_generate => 'MD5',
session_serialize => 'Storable',
);
foreach ( [ session_directory => 'sessions' ],
)
{
my $dir = File::Spec->catfile( $group->data_dir, $_->[1] );
mkpath($dir);
$params{ $_->[0] } = $dir;
}
# will be used below in various ways
use Apache::Session::Flex;
my %session;
tie %session, 'Apache::Session::Flex', undef,
{ Store => 'File',
Lock => 'Null',
Generate => 'MD5',
Serialize => 'Storable',
Directory => $params{session_directory},
};
$session{bar}{baz} = 1;
my $id = $session{_session_id};
untie %session;
#------------------------------------------------------------
$group->add_test
( name => 'can_session',
description => 'make sure request->can("session")',
interp_params => \%params,
component => <<'EOF',
I <% $m->can('session') ? 'can' : 'cannot' %> session
EOF
expect => <<'EOF',
I can session
EOF
);
#------------------------------------------------------------
$group->add_test
( name => 'isa_session',
description => 'make sure request->session->isa("Apache::Session")',
interp_params => \%params,
component => <<'EOF',
$m->session ref: <% ref $tied %>
<%init>
my $s = $m->session;
my $tied = tied(%$s);
%init>
EOF
expect => <<'EOF',
$m->session ref: Apache::Session::Flex
EOF
);
#------------------------------------------------------------
$group->add_test
( name => 'session_store',
description => 'store something in the session',
interp_params => \%params,
component => <<"EOF",
stored
<%init>
\$m->session( session_id => '$id' )->{foo} = 'bar';
%init>
EOF
expect => <<'EOF',
stored
EOF
);
#------------------------------------------------------------
$group->add_test
( name => 'session_read',
description => 'read stored data from the session',
interp_params => \%params,
component => <<"EOF",
read: <% \$m->session( session_id => '$id' )->{foo} %>
EOF
expect => <<'EOF',
read: bar
EOF
);
#------------------------------------------------------------
$group->add_test
( name => 'session_allow_invalid',
description => 'test that session id can be invalid',
interp_params => \%params,
component => <<'EOF',
ok
<%init>
$m->session( session_id => 'abcdef' );
%init>
EOF
expect => <<'EOF',
ok
EOF
);
#------------------------------------------------------------
$group->add_test
( name => 'session_do_not_allow_invalid',
description => 'test that session id cannot be invalid',
interp_params => { %params,
session_allow_invalid_id => 0 },
component => <<'EOF',
<%init>
$m->session( session_id => 'abcdef' );
%init>
EOF
expect_error => qr/Invalid session id/,
);
#------------------------------------------------------------
$group->add_test
( name => 'session_always_write_on_1',
description => 'test always write (part 1)',
interp_params => \%params,
component => <<"EOF",
bar:baz: <% \$m->session( session_id => '$id' )->{bar}{baz} %>
<%init>
\$m->session( session_id => '$id' )->{bar}{baz} = 50;
%init>
EOF
expect => <<'EOF',
bar:baz: 50
EOF
);
#------------------------------------------------------------
$group->add_test
( name => 'session_always_write_2',
description => 'test always write (part 2)',
interp_params => \%params,
component => <<"EOF",
bar:baz: <% \$m->session( session_id => '$id' )->{bar}{baz} %>
EOF
expect => <<'EOF',
bar:baz: 50
EOF
);
#------------------------------------------------------------
$group->add_test
( name => 'session_always_write_off_1',
description => 'test turning off always write (part 1)',
interp_params => { %params,
session_always_write => 0 },
component => <<"EOF",
bar:baz: <% \$m->session( session_id => '$id' )->{bar}{baz} %>
<%init>
\$m->session( session_id => '$id' )->{bar}{baz} = 100;
%init>
EOF
expect => <<'EOF',
bar:baz: 100
EOF
);
#------------------------------------------------------------
$group->add_test
( name => 'session_always_write_off_2',
description => 'test turning off always write (part 2)',
interp_params => { %params,
session_always_write => 0 },
component => <<"EOF",
bar:baz: <% \$m->session( session_id => '$id' )->{bar}{baz} %>
EOF
expect => <<'EOF',
bar:baz: 50
EOF
);
#------------------------------------------------------------
$group->add_support( path => '/as/subrequest',
component => <<'EOF',
foo: <% $m->session->{foo} %>
EOF
);
#------------------------------------------------------------
$group->add_test( name => 'subrequest1',
description => 'Make sure session is shared with subrequests',
interp_params => \%params,
component => <<'EOF',
Parent
% $m->session->{foo} = 'bar';
% $m->subexec( '/basic-session/as/subrequest' );
EOF
expect => <<'EOF',
Parent
foo: bar
EOF
);
#------------------------------------------------------------
$group->add_test
( name => 'delete_session',
description => 'make sure delete_session method works',
interp_params => \%params,
component => <<'EOF',
% $m->session->{foo} = 'foo';
<% $m->session->{foo} %>
% $m->delete_session;
foo does <% exists $m->session->{foo} ? '' : 'not' %> exist
EOF
expect => <<'EOF',
foo
foo does not exist
EOF
);
#------------------------------------------------------------
return $group;
}
MasonX-Request-WithApacheSession-0.31/t/99-pod.t 0000444 0035230 0036653 00000000721 10732320526 022242 0 ustar lhotskyb Domain Users #!/usr/bin/perl -w
use strict;
use vars qw( @files );
BEGIN {
eval "require File::Find::Rule";
if ($@)
{
print "1..1\nok 1 # skip File::Find::Rule not installed\n";
exit;
}
@files = File::Find::Rule->file()->name( '*.pm', '*.pod' )->in( 'blib/lib' );
}
use Test::More tests => scalar @files;
eval "use Test::Pod 0.95";
SKIP: {
skip "Test::Pod 0.95 not installed.", scalar @files if $@;
pod_file_ok( $_ ) for @files;
}
MasonX-Request-WithApacheSession-0.31/Makefile.PL 0000444 0035230 0036653 00000002115 10732320526 022542 0 ustar lhotskyb Domain Users # Note: this file was auto-generated by Module::Build::Compat version 0.03
unless (eval "use Module::Build::Compat 0.02; 1" ) {
print "This module requires Module::Build to install itself.\n";
require ExtUtils::MakeMaker;
my $yn = ExtUtils::MakeMaker::prompt
(' Install Module::Build now from CPAN?', 'y');
unless ($yn =~ /^y/i) {
die " *** Cannot install without Module::Build. Exiting ...\n";
}
require Cwd;
require File::Spec;
require CPAN;
# Save this 'cause CPAN will chdir all over the place.
my $cwd = Cwd::cwd();
CPAN::Shell->install('Module::Build::Compat');
CPAN::Shell->expand("Module", "Module::Build::Compat")->uptodate
or die "Couldn't install Module::Build, giving up.\n";
chdir $cwd or die "Cannot chdir() back to $cwd: $!";
}
eval "use Module::Build::Compat 0.02; 1" or die $@;
Module::Build::Compat->run_build_pl(args => \@ARGV);
require Module::Build;
Module::Build::Compat->write_makefile(build_class => 'Module::Build');
MasonX-Request-WithApacheSession-0.31/Changes 0000444 0035230 0036653 00000011642 10732320526 022070 0 ustar lhotskyb Domain Users 0.31 December 18, 2007
- Patch by Michael Scoltock (scoltock . at . ictp.it ) to fix subexec
- Patch submitted as guest user to fix the CGI Environment Problems.
0.30 March 19, 2004
- MasonX::Request::WithApacheSession is now a very thin wrapper around
Apache::Session::Wrapper (it's a wrapper wrapper!). This change
should be transparent to users.
- Because of the above, you can now do this:
PerlSetVar MasonSessionCookieExpires session
and get a cookie which expires when the browser is closed. Requested
by Herald (RT #5615).
0.25 February 11, 2004
- Ken broke Module::Build's backwards compatibility with older
passthrough Makefile.PL scripts and went on vacation. This version
has no code changes besides a newly generated Makefile.PL.
0.24 November 5, 2003
- This distro now includes the MasonX::Request::WithMultiSession
module. This module tries to help solve the problem of allowing a
user to open multiple browser windows, each with their own individual
session-based state.
- Switched to Module::Build.
- Distribution is signed with Module::Signature.
0.23 August 15, 2003
- Changed the 01-basic.t tests to not use the
Apache::Session::Lock::File module, since file locking may not work on
all platforms.
0.22 August 12, 2003
- Fixed handling of the session_long_read_len and session_textsize
parameters. Reported by Mario Truyens.
0.21 March 19, 2003
- Fixed the docs, which erroneously indicated that the session_handle
and session_lock_handle parameter could be set via an Apache config
file.
0.20 February 21, 2003
- Added a session_args_param constructor parameter, which tells this
module to look in the request args for a session id. This can be used
in combination with cookies or by itself.
- Cookies are now sent when the request object is created, not when
the session() method is first called.
- Rewrote the internals a bit to clean things up. All tests pass but
as always, use caution when deploying a new release.
0.12 January 4, 2003
- Setting the session_cookie_resend parameter to false caused the
module to never send a cookie at all. Reported and fixed by Michele
Gherlone.
0.11 December 17, 2002
- Make sure Mason modules are loaded before declaring
HTML::Mason::Exception subclass. Previously, loading this module
before loading HTML::Mason::Exceptions caused this module to die.
- Fixed a pod nit.
0.10 not released because I'm dumb
- This module would not set cookies properly when run with mod_perl
2.0 or when run under CGIHandler. Even though it loaded CGI::Cookie,
it would attempt call ->bake on the cookie object, which only works
with Apache::Cookie.
- Added session_cookie_resend parameter, which allows you to tell this
module to not resend cookies every time the session is accessed. The
default remains the same, which is to resend the cookie every time the
session is accessed. Based on a patch from John Armstrong.
0.09 October 21, 2002
- ** Change the default cookie name to
"MasonX-Request-WithApacheSession". This means if you were using
previous versions of the module with the default cookie name and you
install this one, old cookies will not be recognized. You can
explicitly set the cookie name to the old value,
"HTML-Mason-Request-WithApacheSession", if this is a problem.
- The previous version would try to use Apache::Cookie for
reading/setting cookies even if it couldn't load Apache::Cookie.
0.08 October 19, 2002
- ** Renamed to MasonX::Request::WithApacheSession. MasonX is the new
official namespace for classes distributed outside of the Mason core
that extend Mason.
This means that when you install this release, it will not replace
HTML::Mason::Request::WithApacheSession. Make sure you change your
usage of this class in your httpd.conf or handler.pl file!
- Get cookie (and session id) in the constructor, so that the session
is available from the request object returned by
ApacheHandler->prepare_request(). Bug report by Matthias Juchem.
- Try to use Apache::Cookie if we're running under mod_perl, but
fallback to CGI::Cookie if necessary.
0.07 August 19, 2002 (from Taiwan)
- Some parameters which should have allowed undef were not allowing
it.
- When an incoming cookie contained an invalid session id and a new
session was created, the old session id was still being set in the
cookie for that request. Reported by Warren Welch.
0.06 August 1, 2002
- Every call to $m->session was baking a new cookie. Reported by
Chris Huseman.
- Added $m->delete_session method. Suggested by Chris Huseman.
0.05 July 23, 2002
- Use Request->alter_superclass method available in Mason 1.12.
0.04 July 17, 2002
- Make it play nicer with a caching Class::Container.
0.03 July 15, 2002
- Make it work with upcoming Class::Container (which does more
caching).
- Fix handling of subrequests.
0.02 June 20, 2002
- Make it work with CGIHandler as well.
- Add Apache::Session to prereq (duh!). Reported by Alex Muntada.
0.01 June 12, 2002
- initial release
MasonX-Request-WithApacheSession-0.31/MANIFEST 0000444 0035230 0036653 00000000420 10732320526 021716 0 ustar lhotskyb Domain Users Build.PL
Changes
lib/MasonX/Request/WithApacheSession.pm
lib/MasonX/Request/WithMultiSession.pm
Makefile.PL
MANIFEST This list of files
META.yml Module meta-data (added by MakeMaker)
README
t/01-basic.t
t/03-multi.t
t/99-pod.t
SIGNATURE Added here by Module::Build
MasonX-Request-WithApacheSession-0.31/SIGNATURE 0000644 0035230 0036653 00000002567 10732320531 022065 0 ustar lhotskyb Domain Users This file contains message digests of all files listed in MANIFEST,
signed via the Module::Signature module, version 0.55.
To verify the content in this distribution, first make sure you have
Module::Signature installed, then type:
% cpansign -v
It will check each file's integrity, as well as the signature's
validity. If "==> Signature verified OK! <==" is not displayed,
the distribution may already have been compromised, and you should
not run its Makefile.PL or Build.PL.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
SHA1 2ab049876d19c28cd2bca431cfd41dff897f27ce Build.PL
SHA1 62d421417188a6e4c09dd6b64f42da43348cf9b8 Changes
SHA1 162e0666668661b86acc74ad876b01739ca8d913 MANIFEST
SHA1 0971bb4e0a0b29d6a7f1824f378b359b6a9bcc51 META.yml
SHA1 cd14ada78fb37a0d926edd86eddcdf7f939de582 Makefile.PL
SHA1 98a5634e712ee539f6d77740f7114ad526768ca6 README
SHA1 23fb096e7b68c1abdfb4d03b70d24763937a36bd lib/MasonX/Request/WithApacheSession.pm
SHA1 0c2d3674d81fafa9db81a2b39cbe1aadbc645396 lib/MasonX/Request/WithMultiSession.pm
SHA1 48f75bce66de312576ad4f41ebcfa75fbb32d792 t/01-basic.t
SHA1 59369ef6ccd08b841fdf08b3d18e7657a3140fe3 t/03-multi.t
SHA1 77232b92127c5f3069f8b6d349aa5ef49ca1b9d4 t/99-pod.t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
iD8DBQFHaaFZJ31bvXcnwRcRAoEQAJ0QNIfPoiQxxjiPwgGZiO81D2B5rACfQg4k
9nq39A5PSDw+0AS2qZLtQI8=
=HQD+
-----END PGP SIGNATURE-----