Apache-ASP

 view release on metacpan or  search on metacpan

ASP.pm  view on Meta::CPAN


# other common modules load now, these are optional though, so we do not error upon failure
# just do this once perl mod_perl parent startup
unless($LoadModPerl++) {
    my @load_modules = qw( Config lib Time::HiRes );
    if($ENV{MOD_PERL}) {
	# Only pre-load these if in a mod_perl environment for sharing memory post fork.
	# These will not be loaded then for CGI until absolutely necessary at runtime
	push(@load_modules, qw( 
          mod_perl
          MLDBM::Serializer::Data::Dumper Devel::Symdump CGI
          Apache::ASP::StateManager Apache::ASP::Session Apache::ASP::Application
          Apache::ASP::StatINC Apache::ASP::Error
          )
	    );
    }
    
    for my $module ( @load_modules ) {
         eval "use $module ();";
    }

ASP.pm  view on Meta::CPAN

   SendMail => "No mailing support",
   
   StateDB => 
   'cannot load StateDB '.
   'must be a valid perl module with a db tied hash interface '.
   'such as: SDBM_File (default), or DB_File',
   
   StateSerializer =>
   'cannot load StateSerializer '.
   'must be a valid serializing perl module for use with MLDBM '.
   'such as Data::Dumper (default), or Storable',

   StatINC => "You need this module for StatINC, please download it from CPAN",
   
   'Cache' => "You need this module for xml output caching",

   XSLT => 'Cannot load XML::XSLT.  Try installing the module.',

  );


ASP.pm  view on Meta::CPAN

	    }
	}
    }

COMPILE_INCLUDE_PARSE:
    
    my $parse_data = $self->Parse($include);
    my $no_cache = $self->{no_cache};
    my $data;

#    use Data::Dumper qw(Dumper);
#    print STDERR Dumper($include, $parse_data);
#    $self->Debug($self);

    if ($parse_data->{is_perl}) {
       my $sub = $self->CompilePerl($parse_data->{data}, $subid, $package);

       # for perl with subs in it, do not cache the code compilation
       # to help prevent my closure problems for newbies, --jc 2/11/2003
       unless($no_cache) {
	   $no_cache = $self->TestForSubs($parse_data->{data});

ASP.pm  view on Meta::CPAN

=item StateCache

Deprecated as of 2.23.  There is no equivalent config for
the functionality this represented from that version on.
The 2.23 release represented a significant rewrite
of the state management, moving to MLDBM::Sync for its
subsystem.

=item StateSerializer

default Data::Dumper, you may set this to Storable for 
faster serialization and storage of data into state objects.
This is particularly useful when storing large objects in
$Session and $Application, as the Storable.pm module has a faster
implementation of freezing and thawing data from and to
perl structures.  Note that if you are storing this much
data in your state databases, you may want to use 
DB_File since it does not have the default 1024 byte limit 
that SDBM_File has on key/value lengths.

This configuration setting may be changed in production
as the state database's serializer type is stored
in the internal state manager which will always use 
Data::Dumper & SDBM_File to store data.

  PerlSetVar StateSerializer Data::Dumper

=head2 Sessions

=item CookiePath

URL root that client responds to by sending the session cookie.
If your asp application falls under the server url "/asp", 
then you would set this variable to /asp.  This then allows
you to run different applications on the same server, with
different user sessions for each application.

ASP.pm  view on Meta::CPAN

be set to some directory not under the www server document root,
for security reasons, on a production site.

Usually a 

 chmod -R -0777 eg

will take care of the write access issue for initial testing purposes.

Failing write access being the problem, try upgrading your version
of Data::Dumper and MLDBM, which are the modules used to write the 
state files.

=head2 Sessions

=item How can I use $Session to store complex data structures.

Very carefully.  Please read the $Session documentation in 
the OBJECTS section.  You can store very complex objects
in $Session, but you have to understand the limits, and 
the syntax that must be used to make this happen.

ASP.pm  view on Meta::CPAN

   before was engineering around SDBM_File's shortcomings.

 - Fix for SessionSerialize config, which broke in 2.23
   Also, added t/session_serialize.t to test suite to catch
   this problem in the future.

=item $VERSION = 2.23; $DATE="10/11/2001";

 +Make sure a couple other small standard modules get loaded
  upon "PerlModule Apache::ASP", like Time::HiRes, Class::Struct,
  and MLDBM::Serializer::Data::Dumper.  If not available
  these modules won't cause errors, but will promote child httpd
  RAM sharing if they are.

 -XMLSubs args parsing fix so an arg like z-index
  does not error under UseStrict.  This is OK now:

   <my:layer z-index=3 top=0 left=0> HTML </my:layer>

 -Only remove outermost <SCRIPT> tags from global.asa
  for IIS/PerlScript compatibility.  Used to remove

ASP.pm  view on Meta::CPAN

  by default.  Set to -1,-2 for internal debugging
  for Debug settings 1 & 2.

 +Both StateSerializer & StateDB can be changed 
  without affecting a live web site, by storing 
  the configurations for $Application & $Session 
  in an internal database, so that if $Session was
  created with SDBM_File for the StateDB (default),
  it will keep this StateDB setting until it ends.

 +StateSerializer config setting.  Default Data::Dumper,
  can also be set to Storable.  Controls how data is
  serialized before writing to $Application & $Session.

 +Beefed up the make test suite.

 +Improved the locking, streamlining a bit of the 
  $Application / $Session setup process.  Bench is up to 
  22 from 21 hits / sec on dev NT box.

 +Cut more fat for faster startup, now on my dev box 

META.json  view on Meta::CPAN

      },
      "configure" : {
         "requires" : {
            "ExtUtils::MakeMaker" : "0"
         }
      },
      "runtime" : {
         "requires" : {
            "Carp" : "0",
            "Class::Struct" : "0",
            "Data::Dumper" : "0",
            "Digest::MD5" : "0",
            "Fcntl" : "0",
            "File::Basename" : "0",
            "MLDBM" : "0",
            "MLDBM::Sync" : "0",
            "SDBM_File" : "0"
         }
      }
   },
   "release_status" : "stable",

META.yml  view on Meta::CPAN

  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: '1.4'
name: Apache-ASP
no_index:
  directory:
    - t
    - inc
requires:
  Carp: '0'
  Class::Struct: '0'
  Data::Dumper: '0'
  Digest::MD5: '0'
  Fcntl: '0'
  File::Basename: '0'
  MLDBM: '0'
  MLDBM::Sync: '0'
  SDBM_File: '0'
version: 2.63

Makefile.PL  view on Meta::CPAN


my $mtime_makefile = (stat('Makefile'))[9] || 0;
my $fresh_makefile = ($mtime_makefile > time() - 1200) ? 1 : 0;

my $necessary_modules = {
#    'Apache' => 'Make sure your installation of mod_perl is complete',
    'Class::Struct' => "Apache::ASP->Loader() precompile scripts functionality",
    'MLDBM' => 'This is used for reading and writing multi-level hashes on disk',
    'MLDBM::Sync 0.25' => 'Support for State dbms like $Session & $Application',		 
    'SDBM_File' => 'Internal databases used for state files, like $Session',
    'Data::Dumper' => 'Serializes data for MLDBM',
    'Fcntl' => 'Used for file locking constants',
    'File::Basename' => "Used for tests during 'make test'",
    'Digest::MD5' => '32 byte hash algorithm for cookie session-id',
    'Carp' => 'Provides critical error messaging with confess()',
};

my $optional_modules = 
  {
   'Devel::Symdump' => 'Used for StatINC setting, which reloads modules dynamically',
   'Win32::OLE' => { 

Makefile.PL  view on Meta::CPAN

    print "+++ Looks good!  You are ready to install Apache::ASP! +++ \n\n";
} 

use ExtUtils::MakeMaker;
&WriteMakefile(
	       'NAME' => "Apache::ASP",
	       'VERSION_FROM' => 'CHANGES', # finds $VERSION
	       'PREREQ_PM' => {
			       'Carp' => 0,
			       'Class::Struct' => 0,
			       'Data::Dumper' => 0,
			       'Fcntl' => 0,
			       'File::Basename' => 0,
			       'Digest::MD5' => 0,
			       'MLDBM' => 0,
			       'SDBM_File' => 0,
			       'MLDBM::Sync' => 0,
			      },
               'EXE_FILES' => [ 'asp-perl' ],
	       'clean' => { FILES => 't/long_directory_path_test t/.cache t/.state t/session_events/.state t/null/.state Makefile.old' },
	      );

README  view on Meta::CPAN


          PerlSetVar StateDB SDBM_File

    StateCache
        Deprecated as of 2.23. There is no equivalent config for the
        functionality this represented from that version on. The 2.23 release
        represented a significant rewrite of the state management, moving to
        MLDBM::Sync for its subsystem.

    StateSerializer
        default Data::Dumper, you may set this to Storable for faster
        serialization and storage of data into state objects. This is
        particularly useful when storing large objects in $Session and
        $Application, as the Storable.pm module has a faster implementation of
        freezing and thawing data from and to perl structures. Note that if you
        are storing this much data in your state databases, you may want to use
        DB_File since it does not have the default 1024 byte limit that
        SDBM_File has on key/value lengths.

        This configuration setting may be changed in production as the state
        database's serializer type is stored in the internal state manager which
        will always use Data::Dumper & SDBM_File to store data.

          PerlSetVar StateSerializer Data::Dumper

  Sessions
    CookiePath
        URL root that client responds to by sending the session cookie. If your
        asp application falls under the server url "/asp", then you would set
        this variable to /asp. This then allows you to run different
        applications on the same server, with different user sessions for each
        application.

          PerlSetVar CookiePath /

README  view on Meta::CPAN

        should be set to some directory not under the www server document root,
        for security reasons, on a production site.

        Usually a

         chmod -R -0777 eg

        will take care of the write access issue for initial testing purposes.

        Failing write access being the problem, try upgrading your version of
        Data::Dumper and MLDBM, which are the modules used to write the state
        files.

  Sessions
    How can I use $Session to store complex data structures.
        Very carefully. Please read the $Session documentation in the OBJECTS
        section. You can store very complex objects in $Session, but you have to
        understand the limits, and the syntax that must be used to make this
        happen.

        In particular, stay away from statements that that have more than one

README  view on Meta::CPAN

           Make use of MLDBM::Sync::SDBM_File, where search database
           before was engineering around SDBM_File's shortcomings.

         - Fix for SessionSerialize config, which broke in 2.23
           Also, added t/session_serialize.t to test suite to catch
           this problem in the future.

    $VERSION = 2.23; $DATE="10/11/2001";
         +Make sure a couple other small standard modules get loaded
          upon "PerlModule Apache::ASP", like Time::HiRes, Class::Struct,
          and MLDBM::Serializer::Data::Dumper.  If not available
          these modules won't cause errors, but will promote child httpd
          RAM sharing if they are.

         -XMLSubs args parsing fix so an arg like z-index
          does not error under UseStrict.  This is OK now:

           <my:layer z-index=3 top=0 left=0> HTML </my:layer>

         -Only remove outermost <SCRIPT> tags from global.asa
          for IIS/PerlScript compatibility.  Used to remove

README  view on Meta::CPAN

          by default.  Set to -1,-2 for internal debugging
          for Debug settings 1 & 2.

         +Both StateSerializer & StateDB can be changed 
          without affecting a live web site, by storing 
          the configurations for $Application & $Session 
          in an internal database, so that if $Session was
          created with SDBM_File for the StateDB (default),
          it will keep this StateDB setting until it ends.

         +StateSerializer config setting.  Default Data::Dumper,
          can also be set to Storable.  Controls how data is
          serialized before writing to $Application & $Session.

         +Beefed up the make test suite.

         +Improved the locking, streamlining a bit of the 
          $Application / $Session setup process.  Bench is up to 
          22 from 21 hits / sec on dev NT box.

         +Cut more fat for faster startup, now on my dev box 

build/global/global.asa  view on Meta::CPAN


use Data::Dumper;
use vars qw(%FILES %ALIASES %LINKS $ASP $DOCINIT $DUMP $Site $LINKS_MATCH $VAR1);
use Time::HiRes;
use Data::Dumper;
use Digest::MD5 qw( md5_hex );
use SiteTags;
use strict;

$DUMP = "/tmp/aspbuilddumpdata";
%FILES = ('index' => 'INTRO',
	  'install' => 'INSTALL',
	  'changes' => 'CHANGES',
	  'config' => 'CONFIG',
	  'sessions' => 'SESSIONS',

build/global/global.asa  view on Meta::CPAN

    if($Request->QueryString('site')) {
	$Site = 1;
    }
}

sub Script_OnEnd {
    $Response->Write("\n");
}

sub dmp {
    Data::Dumper->Dump([@_]);
}

sub dbg {
    $Response->Debug(@_);
}

sub doc_init {
    local $/ = undef;
    open(DUMP, $DUMP);
    my $dump = <DUMP>;

build/global/global.asa  view on Meta::CPAN

	    $level = $item->{level};
	} else {
	    push(@{$levels[0]->{stack}}, $item);	
	}

#	last if $count++ > 20;
    }

#    warn(Time::HiRes::time - $time);
    open(DUMP, ">$DUMP");
    print DUMP Data::Dumper->Dump([{ checksum => $new_checksum, ASP => $ASP}]);
    close DUMP;
    
    dbg(dmp($ASP));
}

sub pod2html {
    my($body, $title, $depth) = @_;

    if($title) {
	$depth ||= 1;

lib/Apache/ASP/Response.pm  view on Meta::CPAN


package Apache::ASP::Response;

use Apache::ASP::Collection;

use strict;
no strict qw(refs);
use vars qw(@ISA @Members %LinkTags $TextHTMLRegexp);
@ISA = qw(Apache::ASP::Collection);
use Carp qw(confess);
use Data::Dumper qw(DumperX);
use bytes;

@Members = qw( Buffer Clean ContentType Expires ExpiresAbsolute Status );

# used for session id auto parsing
%LinkTags = (
	     'a' => 'href',
	     'area' => 'href',
	     'form' => 'action',
	     'frame' => 'src',

lib/Apache/ASP/Response.pm  view on Meta::CPAN


    1;
}

# do cookies, try our best to emulate cookie collections
sub AddCookieHeaders {
    my $self = shift;
    my $cookies = $self->{'Cookies'};
    my $dbg = $self->{asp}{dbg};

#    print STDERR Data::Dumper::DumperX($cookies);

    my($cookie_name, $cookie);
    for $cookie_name (sort keys %{$cookies}) {
	# skip key used for session id
	if($Apache::ASP::SessionCookieName eq $cookie_name) {
	    confess("You can't use $cookie_name for a cookie name ".
		    "since it is reserved for session management"
		    );
	}
	

lib/Apache/ASP/State.pm  view on Meta::CPAN

package Apache::ASP::State;

use MLDBM;
use MLDBM::Sync 0.25;
use MLDBM::Sync::SDBM_File;
use SDBM_File;
use Data::Dumper;

use strict;
no strict qw(refs);
use vars qw(%DB %CACHE $DefaultGroupIdLength);
use Fcntl qw(:flock O_RDWR O_CREAT);
$DefaultGroupIdLength = 2;

# Database formats supports and their underlying extensions
%DB = (
       SDBM_File => ['.pag', '.dir'],

lib/Apache/ASP/State.pm  view on Meta::CPAN

		my $error = $!;
		-d $create_dir || $self->{asp}->Error("can't create group dir $create_dir: $error");
	    }
	}
	$self->UmaskRestore;
    }

    # INIT MLDBM::Sync DBM
    { 
	local $MLDBM::UseDB = $state_db || 'SDBM_File';
	local $MLDBM::Serializer = $state_serializer || 'Data::Dumper';
	# clear current tied relationship first, if any
	$self->{dbm} = undef; 
	local $SIG{__WARN__} = sub {};
	
	my $error;
	$self->{file} =~ /^(.*)$/; # untaint
	$self->{file} = $1;
	local $MLDBM::RemoveTaint = 1;
	$self->{dbm} = &MLDBM::Sync::TIEHASH('MLDBM', $self->{file}, O_RDWR|O_CREAT, $self->{file_perms});
	$asp->{dbg} && $asp->Debug("creating dbm for file $self->{file}, db $MLDBM::UseDB, serializer: $MLDBM::Serializer");
	$error = $! || 'Undefined Error';


	if(! $self->{dbm}) {
	    $self->{asp}->Error(qq{
Cannot tie to file $self->{file}, $error !!
Make sure you have the permissions on the directory set correctly, and that your
version of Data::Dumper is up to date. Also, make sure you have set StateDir to 
to a good directory in the config file.  StateDir defaults to Global/.state
});
	}
    }

    $self;
}

sub Init   { shift->{dbm}->CLEAR(); }
sub Size   { shift->{dbm}->SyncSize; }

lib/Apache/ASP/StateManager.pm  view on Meta::CPAN

);

$SessionTimeout = 20;
$StateManager   = 10;

# Some OS's have hashed directory lookups up to 16 bytes, so we leave room
# for .lock extension ... nevermind, security is more important, back to 32
# $SessionIDLength = 11;
$SessionIDLength = 32;
$DefaultStateDB = 'SDBM_File';
$DefaultStateSerializer = 'Data::Dumper';

sub InitState {
    my $self = shift;
    my $r = $self->{r};
    my $global_asa = $self->{GlobalASA};

    ## STATE INITS
    # what percent of the session_timeout's time do we garbage collect
    # state files and run programs like Session_OnEnd and Application_OnEnd
    $self->{state_manager} = &config($self, 'StateManager', undef, $Apache::ASP::StateManager);

site/changes.html  view on Meta::CPAN

   Also, added t/session_serialize.t to test suite to catch
   this problem in the future.
</pre></font>
	
	<p>
	<a name=%24VERSION%20%3D%2024674da9c></a>
	<font face=verdana><font class=title size=+0 color=#555555><b>$VERSION = 2.23; $DATE="10/11/2001";</b></font>
<font face="courier new" size=3><pre>
 +Make sure a couple other small standard modules get loaded
  upon &quot;PerlModule Apache::ASP&quot;, like Time::HiRes, Class::Struct,
  and MLDBM::Serializer::Data::Dumper.  If not available
  these modules won&#39;t cause errors, but will promote child httpd
  RAM sharing if they are.

 -XMLSubs args parsing fix so an arg like z-index
  does not error under UseStrict.  This is OK now:

   &lt;my:layer z-index=3 top=0 left=0&gt; HTML &lt;/my:layer&gt;

 -Only remove outermost &lt;SCRIPT&gt; tags from global.asa
  for IIS/PerlScript compatibility.  Used to remove

site/changes.html  view on Meta::CPAN

  by default.  Set to -1,-2 for internal debugging
  for Debug settings 1 &amp; 2.

 +Both StateSerializer &amp; StateDB can be changed 
  without affecting a live web site, by storing 
  the configurations for $Application &amp; $Session 
  in an internal database, so that if $Session was
  created with SDBM_File for the StateDB (default),
  it will keep this StateDB setting until it ends.

 +StateSerializer config setting.  Default Data::Dumper,
  can also be set to Storable.  Controls how data is
  serialized before writing to $Application &amp; $Session.

 +Beefed up the make test suite.

 +Improved the locking, streamlining a bit of the 
  $Application / $Session setup process.  Bench is up to 
  22 from 21 hits / sec on dev NT box.

 +Cut more fat for faster startup, now on my dev box 

site/config.html  view on Meta::CPAN

</pre></font>Deprecated as of 2.23.  There is no equivalent config for
the functionality this represented from that version on.
The 2.23 release represented a significant rewrite
of the state management, moving to MLDBM::Sync for its
subsystem.</font>
	
	<p>
	<a name=StateSeriali106736b1></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>StateSerializer</b></font>
<font face="courier new" size=3><pre>
</pre></font>default Data::Dumper, you may set this to Storable for 
faster serialization and storage of data into state objects.
This is particularly useful when storing large objects in
$Session and $Application, as the Storable.pm module has a faster
implementation of freezing and thawing data from and to
perl structures.  Note that if you are storing this much
data in your state databases, you may want to use 
DB_File since it does not have the default 1024 byte limit 
that SDBM_File has on key/value lengths.
<font face="courier new" size=3><pre>
</pre></font>This configuration setting may be changed in production
as the state database&#39;s serializer type is stored
in the internal state manager which will always use 
Data::Dumper &amp; SDBM_File to store data.
<font face="courier new" size=3><pre>
  PerlSetVar StateSerializer Data::Dumper
</pre></font>
	
	<p>
	<a name=Sessions></a>
	<font face=verdana><font class=title size=+0 color=#555555><b>Sessions</b></font>
</font>
	
	<p>
	<a name=CookiePath></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>CookiePath</b></font>

site/eg/global_asa_demo.asp  view on Meta::CPAN

	my $session_data = $session ? { %$session } : undef;

	my $session_time = ($Application->{$_} eq '?') ?
		"in session" : "$Application->{$_} seconds";

	%>
	<tr bgcolor="#c0c0c0">
		<td><%=substr($session_id, 0, 6)."..."%></td>
		<td><%=$session_time%></td>
	</tr>	
	<tr><td colspan=2><pre><%=$session_data ? Data::Dumper->Dump([$session_data]) : '' %></pre></td></tr>

	<tr><td colspan=2><hr size=1></td></tr>
	<%
}
%>
</table>
</center>
<p>
To see multiple sessions listed you may  
create a 2nd session by closing and then reopening

site/faq.html  view on Meta::CPAN

Default for Global is the directory the script is in (e.g. &#39;.&#39;), but should
be set to some directory not under the www server document root,
for security reasons, on a production site.
<font face="courier new" size=3><pre>
</pre></font>Usually a 
<font face="courier new" size=3><pre>
 chmod -R -0777 eg
</pre></font>will take care of the write access issue for initial testing purposes.
<font face="courier new" size=3><pre>
</pre></font>Failing write access being the problem, try upgrading your version
of Data::Dumper and MLDBM, which are the modules used to write the 
state files.</font>
	
	<p>
	<a name=Sessions></a>
	<font face=verdana><font class=title size=+0 color=#555555><b>Sessions</b></font>
</font>
	
	<p>
	<a name=How%20can%20I%20us65e9eed9></a>
	<font face=verdana><font class=title size=-1 color=#555555><b>How can I use $Session to store complex data structures.</b></font>



( run in 0.428 second using v1.01-cache-2.11-cpan-4d50c553e7e )