ASP4

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN



2011-07-09    v1.049
[Bug Fixes]
  - v1.048 broke session cookies.
  - Upgrade to v1.049 (quick).

2011-07-07    v1.048
[Bug Fixes]
  - <% $Response->Status(404); return $Response->End; %> DID NOT WORK.
    Instead it continued processing other ContentPlaceHolders.  Now we check
    to see if $Response->End was called before we process anything else.
  - Still getting some "Content encoding error" messages from FF/Chrome/MSIE but
    we're almost there.

2011-05-19    v1.047
[Bug Fixes]
  - $Response->Expires("30M") wasn't documented.  Now it is.
  - $Response->Expires wasn't working properly.  Now it is. (Always ended up with pre-epoch expiration times).

2011-05-03    v1.046
[Bug Fixes]

Changes  view on Meta::CPAN


2010-10-21    v1.038
  - Another stab at getting http response codes right for errors.

2010-09-25    v1.037
  - Added a couple tweaks here and there to make ASP4 run on Windows a little easier:
    * $Config->web->page_cache_root now does the Right Thing on linux & win32.
    * $Config->web->page_cache_root is automatically created if it does not exist.

2010-09-21    v1.036
  - Added ASP4::StaticHandler to process requests for static files - like images, css, etc.

2010-09-17    v1.035
  - It turns out that if you close the client socket, some browsers complain (Chrome).
    Upgrade recommended.

2010-09-17    v1.034
  - Non-2xx responses are more returned more correctly, albeit with empty bodies.
  - HTTPHandler now caches the @ISA tree in RAM, offering a slight performance boost.
  - Added missing '$r->headers_in' method to ASP4::Mock::RequestRec.

README.markdown  view on Meta::CPAN

    HTML
    );

Please see [Mail::Sendmail](http://search.cpan.org/perldoc?Mail::Sendmail) for further details and examples.

### $Server->RegisterCleanup( sub { ... }, \@args )

After the final response has been sent to the client, the server will execute
your subref and provide it the `\@args` passed in.

This is useful for long-running or asynchronous processes that don't require the
client to wait for a response.

## $Request

An instance of [ASP4::Request](http://search.cpan.org/perldoc?ASP4::Request), the `$Request` object contains specialized methods
for dealing with whatever the browser sent us.

Examples:

### $Request->Cookies( $name )

README.markdown  view on Meta::CPAN

    use ASP4::ConfigLoader;
    my $Config = ASP4::ConfigLoader->load();

See [ASP4::Config](http://search.cpan.org/perldoc?ASP4::Config) for full details on the ASP4 `$Config` object and its usage.

## $Stash

The `$Stash` is a simple hashref that is guaranteed to be the exact same hashref
throughout the entire lifetime of a request.

Anything placed within the `$Stash` at the very beginning of processing a request -
such as in a RequestFilter - will still be there at the very end of the request -
as in a RegisterCleanup handler.

Use the `$Stash` as a great place to store a piece of data for the duration of
a single request.

# DATABASE

While ASP4 __does not require__ its users to choose any specific database (eg: MySQL or PostgreSQL)
or ORM (object-relational mapper) the __recommended__ ORM is [Class::DBI::Lite](http://search.cpan.org/perldoc?Class::DBI::Lite)

inc/Module/Install.pm  view on Meta::CPAN

	return $str;
}

sub _write {
	local *FH;
	open FH, "> $_[0]" or die "open($_[0]): $!";
	foreach ( 1 .. $#_ ) { print FH $_[$_] or die "print($_[0]): $!" }
	close FH or die "close($_[0]): $!";
}

# _version is for processing module versions (eg, 1.03_05) not
# Perl versions (eg, 5.8.1).

sub _version ($) {
	my $s = shift || 0;
	   $s =~ s/^(\d+)\.?//;
	my $l = $1 || 0;
	my @v = map { $_ . '0' x (3 - length $_) } $s =~ /(\d{1,3})\D?/g;
	   $l = $l . '.' . join '', @v if @v;
	return $l + 0;
}

inc/Module/Install/Win32.pm  view on Meta::CPAN


  http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe
      or
  ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe

Please download the file manually, save it to a directory in %PATH% (e.g.
C:\WINDOWS\COMMAND\), then launch the MS-DOS command line shell, "cd" to
that directory, and run "Nmake15.exe" from there; that will create the
'nmake.exe' file needed by this module.

You may then resume the installation process described in README.

-------------------------------------------------------------------------------
END_MESSAGE

}

1;

lib/ASP4.pm  view on Meta::CPAN

  HTML
  );

Please see L<Mail::Sendmail> for further details and examples.

=head3 $Server->RegisterCleanup( sub { ... }, \@args )

After the final response has been sent to the client, the server will execute
your subref and provide it the C<\@args> passed in.

This is useful for long-running or asynchronous processes that don't require the
client to wait for a response.

=head2 $Request

An instance of L<ASP4::Request>, the C<$Request> object contains specialized methods
for dealing with whatever the browser sent us.

Examples:

=head3 $Request->Cookies( $name )

lib/ASP4.pm  view on Meta::CPAN

  use ASP4::ConfigLoader;
  my $Config = ASP4::ConfigLoader->load();

See L<ASP4::Config> for full details on the ASP4 C<$Config> object and its usage.

=head2 $Stash

The C<$Stash> is a simple hashref that is guaranteed to be the exact same hashref
throughout the entire lifetime of a request.

Anything placed within the C<$Stash> at the very beginning of processing a request -
such as in a RequestFilter - will still be there at the very end of the request -
as in a RegisterCleanup handler.

Use the C<$Stash> as a great place to store a piece of data for the duration of
a single request.

=head1 DATABASE

While ASP4 B<does not require> its users to choose any specific database (eg: MySQL or PostgreSQL)
or ORM (object-relational mapper) the B<recommended> ORM is L<Class::DBI::Lite>

lib/ASP4/Config.pm  view on Meta::CPAN

  }# end foreach()

=head1 JSON Config File

ASP4::ASP keeps all of its configuration inside of C</conf/asp4-config.json>

Here is an example:

  {
    "system": {
      "post_processors": [
        
      ],
      "libs": [
        "@ServerRoot@/lib",
        "@ProjectRoot@/lib"
      ],
      "load_modules": [
        "DBI",
        "DBD::SQLite"
      ],

lib/ASP4/ConfigNode/System.pm  view on Meta::CPAN



sub env_vars
{
  my $s = shift;
  
  $s->{env_vars} || { };
}# end env_vars()


sub post_processors
{
  my $s = shift;
  
  @{ $s->{post_processors} || [ ] };
}# end post_processors()


sub settings
{
  my $s = shift;
  
  return $s->{settings} || { };
}# end settings()

1;# return true:

lib/ASP4/ConfigNode/System.pm  view on Meta::CPAN

=head1 PUBLIC PROPERTIES

=head2 libs

A list of library paths that should be included into C<@INC>.

=head2 load_modules

A list of Perl modules that should be loaded automatically.

=head2 post_processors

A list of L<ASP4::ConfigPostProcessor> modules that should be given the ability to alter the config before
it is considered "ready for use" by the rest of the application.

=head2 env_vars

A hash of C<%ENV> variables that should be set.

=head2 settings

lib/ASP4/ConfigNode/Web.pm  view on Meta::CPAN

=head2 www_root

Returns the absolute path to where the normal website files (ASP, images, css, javascripts, etc) are located, 
i.e. C</usr/local/projects/mysite.com/htdocs>

=head2 page_cache_root

Returns the absolute path to where 'compiled' ASP scripts are stored, i.e. C</tmp/PAGE_CACHE>

Since the 'compiled' ASP scripts are overwritten whenever the source ASP script has been changed on disk,
the webserver process must have read/write access to this location.

It is recommended that a temporary path is used - '/tmp' on most Linux distributions.

=head2 request_filters

Returns a list of ConfigNodes that represent individual C<filter> elements in the configuration.

=head2 router

B<*IF*> you have defined a "routes" section in your config - like this:

lib/ASP4/ConfigParser.pm  view on Meta::CPAN

  return bless { }, $class;
}# end new()


sub parse
{
  my ($s, $doc, $root) = @_;
  
  my $config = ASP4::Config->new( $doc, $root );
  
  # Now do any post-processing:
  foreach my $class ( $config->system->post_processors )
  {
    (my $file = "$class.pm") =~ s/::/\//;
    require $file unless $INC{$file};
    $config = $class->new()->post_process( $config );
  }# end foreach()
  
  return $config;
}# end parse()

1;# return true:

lib/ASP4/ConfigPostProcessor.pm  view on Meta::CPAN



sub new
{
  my ($class, %args) = @_;
  
  return bless \%args, $class;
}# end new()


sub post_process($$);

1;# return true:

lib/ASP4/HTTPContext.pm  view on Meta::CPAN

  my $server    = $context->server;
  my $config    = $context->config;
  my $stash     = $context->stash;
  
  # Advanced:
  my $cgi = $context->cgi;
  my $r = $context->r;

=head1 DESCRIPTION

The HTTPContext itself is the root of all request-processing in an ASP4 web application.

There is only one ASP4::HTTPContext instance throughout the lifetime of a request.

=head1 PROPERTIES

=head2 current

Returns the C<ASP4::HTTPContext> object in use for the current HTTP request.

=head2 request

lib/ASP4/Request.pm  view on Meta::CPAN

    $file->SaveAs( "/var/media/$Session->{user_id}/avatar/" . $file->FileName );
  }
  
  if( $Request->ServerVariables("HTTPS") ) {
    # We're under SSL:
  }

=head1 DESCRIPTION

The intrinsic C<$Request> object provides a few easy-to-use methods to simplify
the processing of incoming requests - specifically file uploads and cookies.

=head1 METHODS

=head2 Cookies( [$name] )

Returns a cookie by name, or all cookies if no name is provided.

=head2 ServerVariables( [$name] )

A wrapper around the global C<%ENV> variable.

lib/ASP4/Server.pm  view on Meta::CPAN


The supplied coderef will be executed with its arguments as the request enters
its Cleanup phase.

See L<http://perl.apache.org/docs/2.0/user/handlers/http.html#PerlCleanupHandler> for details.

=head2 Error( [%args] )

Calling C<<$Server->Error()>> without arguments will use the value of C<$@> and
generate a L<ASP4::Error> object from it, then pass it to the C<run(...)> method
of your C<<$Config->errors->error_handler>> for processing.

Please take a look at the documentation for L<ASP4::Error>, L<ASP4::ErrorHandler>
and L<ASP4::ErrorHandler::Remote> for details on how errors are handled.

=head1 BUGS

It's possible that some bugs have found their way into this release.

Use RT L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=ASP4> to submit bug reports.

sbin/asphelper  view on Meta::CPAN

END


sub generic_config
{
  my ($has_db) = @_;

  my $str = <<'EOF';
{
  "system": {
    "post_processors": [
    ],
    "libs": [
      "@ServerRoot@/lib",
      "@ProjectRoot@/common/lib"
    ],
    "load_modules": [
    ],
    "env_vars": {
    },
    "settings": {

t/conf/asp4-config.json  view on Meta::CPAN

{
  "system": {
    "post_processors": [
      
    ],
    "libs": [
      "@ServerRoot@/lib"
    ],
    "load_modules": [
      "DBI",
      "DBD::SQLite"
    ],
    



( run in 0.664 second using v1.01-cache-2.11-cpan-8d75d55dd25 )