Computer Science @ Marlboro  

Session and HTML::Mason testing.

 session id is <% $session->session_id %>
 and currently holds
% for my $key (sort $session->keys){
   <% sprintf("%-20s",$key) %> => <% $session->get($key) %>
% }

color:  
% if ( $session->color ){ The last color you set was '<% $session->color %>'. % } else { There isn't a color set in the session. % }


% my $count = $session->stuff->count;
 $count is '<% $count %>'.
% $count += 2;
% $session->stuff->count( $count );
 $session->stuff->count is '<% $session->stuff->count %>'.

 count==5 changes height to 'very tall'.
% $session->stuff->height('very tall') if $count==5;

 count==11 changes weight to 'very heavy'.
% $session->stuff->weight('very heavy') if $count==11;

%# Previous behavior :
%#   If this part is skipped, $session->stuff->count doesn't change.
%#   But with it in, $session->stuff->count does change.
% if (0) {
%  my $counter = $session->counter;
  $counter is '<% $counter %>;
%  $counter++;
%  $session->counter( $counter );
  $session->counter is '<% $session->counter %>'.
% }
%#
%#  I think what's going on is that 
%#  when the session modules doesn't think that $session has changed,
%#  it doesn't write it out to the database.  
%#  And changing parts down inside the data structure isn't enough
%#  to make it believe that it has changed.
%#
%#  ... OK; looks like my changes to 
%#  Object::Generic::Session (v0.05) fixes this problem
%#  by explicitly marking the session modified 
%#  (using Apache::Session's notion of modified) for any 'set' operation.

 $session->stuff is '<% $session->stuff %>'
 $session->stuff->height is '<% $session->stuff->height %>'
 $session->stuff->weight is '<% $session->stuff->weight %>'
 $session->stuff->foobar is '<% $session->stuff->foobar %>'

% unless ($session->test_guest) {
 session->test_guest is not already set.
%  ($guest) = Person->search(username=>'guest');
 Fetching guest : <% $guest %> (<% ref($guest) %>) and putting it into session.
%  $session->test_guest($guest);
% }
% else {
 session->test_guest is already set.
% }
 session->test_guest = <% $session->test_guest %> (<% ref($session->test_guest) %>)
 session->test_guest->username = '<% $session->guest->username %>'

<& "$HTDOCS/mason/debug.mhtml", %ARGS &>
Jim Mahoney (mahoney@marlboro.edu)
Last modified <% lastmodified() %>
% %# =========================================================== %# $Id: session.html 7 2006-01-13 02:21:11Z mahoney $ % <%args> $color => '' $action => '' % <%init> my $guest; if ($action =~ /clear/i){ $session->remove($_) for $session->keys; } $session->stuff( new Object::Generic ) unless $session->stuff; $session->stuff->height('short') unless $session->stuff->height; $session->stuff->weight('heavy') unless $session->stuff->weight; $session->stuff->count(1) unless $session->stuff->count; $session->counter(1) unless $session->counter; $session->color( $color ) if $color;