ASP4

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

2012-01-30    1.074
  - Explicit calls to $Session->save() are no longer necessary.

2012-01-23    1.073
  - Added $Request->Header($name)
    (Somehow we've gotten along all this time without it.)

2012-01-23    1.072
  - More tweaks on ASP4::SessionStateManager's default internal behavior
    has resulted in some more-than-modest performance gains.
  - Disabling session-state can result in 630 requests/second on a simple 
    master/child "content" page, and 475 requests/second on a page that
    includes reading data from a database (using Class::DBI::Lite of course).
    * Results from `ab` on a Dell E6510 (quad-dual-core-i7, 8GB RAM, Ubuntu 10.10)

2012-01-22    1.071
  - ASP4::HTTPContext now triggers the SessionStateManager's save() method
    when the context is DESTROY'd.

2012-01-22    1.070
  - No longer check session's last-mod when deciding whether or not to save 
    session state at the end of a request.

Changes  view on Meta::CPAN

2010-03-08    v1.023
  - ASP4::HTTPContext now checks to see if any RequestFilters match a uri before
    returning a 404.  This is helpful for SEO optimizations.
  - New feature: $Request->Reroute("/new-uri/?foo=bar")
    * Also very useful for SEO.

2010-03-08    v1.022
  - asphelper's final instructions are now more clear and concise.
  - Fixes a bug that caused active sessions to timeout as though inactive simply
    because they were not changed before the timeout occurred.  Now, $Session->save()
    checks to see if it's been more than 60 seconds since the last time the __lastMod
    was changed - and if it has been more than 60 seconds, the session is saved
    and the __lastMod value is updated to time() - thus preventing expiry of 
    active sessions.

2010-03-08    v1.021
  - Removed a warning that popped up now and then about the use of an uninitialized value.
  - Added a more informative "Yay you're finished!" message after running asphelper.

2010-03-04    v1.020
  - Now asphelper will output sbin/ddl.sql, which contains the structure of the 
    asp_sessions database table.  This is a handy place to start describing the

README.markdown  view on Meta::CPAN

since it has been completely and thoroughly tested to be 100% compatible with ASP4.

For full documentation about [Class::DBI::Lite](http://search.cpan.org/perldoc?Class::DBI::Lite) please view its documentation.

__NOTE:__ [Class::DBI::Lite](http://search.cpan.org/perldoc?Class::DBI::Lite) must be installed in addition to ASP4 as it is a separate library.

# ASP4 QuickStart

Here is an example project to get things going.

In the `data_connections.main` section of `conf/asp4-config.json` you should have
something like this:

    ...
      "main": {
        "dsn":              "DBI:mysql:database_name:data.mywebsite.com",
        "username":         "db-username",
        "password":         "db-pAsswOrd"
      }
    ...

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

	$self->provides( %{ $build->find_dist_packages || {} } );
}

sub feature {
	my $self     = shift;
	my $name     = shift;
	my $features = ( $self->{values}{features} ||= [] );
	my $mods;

	if ( @_ == 1 and ref( $_[0] ) ) {
		# The user used ->feature like ->features by passing in the second
		# argument as a reference.  Accomodate for that.
		$mods = $_[0];
	} else {
		$mods = \@_;
	}

	my $count = 0;
	push @$features, (
		$name => [
			map {

lib/ASP4.pm  view on Meta::CPAN

since it has been completely and thoroughly tested to be 100% compatible with ASP4.

For full documentation about L<Class::DBI::Lite> please view its documentation.

B<NOTE:> L<Class::DBI::Lite> must be installed in addition to ASP4 as it is a separate library.

=head1 ASP4 QuickStart

Here is an example project to get things going.

In the C<data_connections.main> section of C<conf/asp4-config.json> you should have
something like this:

  ...
    "main": {
      "dsn":              "DBI:mysql:database_name:data.mywebsite.com",
      "username":         "db-username",
      "password":         "db-pAsswOrd"
    }
  ...

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

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:

  ...
  "web": {
    ...
    "routes": [
      {
        "name":   "Wiki",
        "path":   "/:lang-:locale/{*page}",
        "target": "/wiki-page.asp",
        "defaults": {

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

The C<$Response> object offers a unified interface to send content back to the client.

=head1 PROPERTIES

=head2 ContentType( [$type] )

Sets or gets the C<content-type> header for the response.  Examples are C<text/html>, C<image/gif>, C<text/csv>, etc.

=head2 Status( [$status] )

Sets or gets the C<Status> header for the response.  See L<http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html> for details.

B<NOTE:> Only the numeric part is necessary - eg: 200, 301, 404, etc.

=head2 Headers()

Returns the L<HTTP::Headers> object that will be used for the outgoing response.

If necessary, you can manipulate this object in any way you see fit.

=head2 Declined

For use within a L<ASP4::RequestFilter> subclass, like this:

  sub run {
    # Permit requests only every other second:
    if( time() % 2 ) {
      return $Response->Declined;
    }
    else {
      $Response->Write("Try again");
      return $Response->End;
    }
  }

=head2 IsClientConnected

lib/ASP4/SessionStateManager/Memcached.pm  view on Meta::CPAN


package 
ASP4::SessionStateManager::Memcached;

# XXX: Experimental memcached session storage.
# TODO: Configuration section is likely to change.

use strict;
use warnings 'all';
use base 'ASP4::SessionStateManager';
use Cache::Memcached;
use JSON::XS;

my $memd;

sub new

lib/ASP4/SessionStateManager/Memcached.pm  view on Meta::CPAN

  return $s;
}# end create()


sub save
{
  my ($s, $id) = @_;
  
  return unless $s->{SessionID};
  no warnings 'uninitialized';
  my $seconds_since_last_modified = time() - ($s->{__lastMod} || 0);
  return unless $s->is_changed || ( $seconds_since_last_modified > 60 );
  $s->{__lastMod} = time();
  $s->sign;
  
  my %clone = %$s;
  my $json = encode_json(\%clone);
  $memd->set( $s->{SessionID}, $json, $s->{__ttl} );
}# end save()


sub reset

sbin/asp4-deploy  view on Meta::CPAN


Required.

=head2 --target=/var/www/myweb.com

Optional.  Defaults to the current directory.

=head1 DESCRIPTION

C<asp4-deploy> behaves differently the B<first time> you deploy an app than it does
the second, third or tenth times.

=head2 The First Deployment

=over 4

=item Step 1

Unzips the tar.gz archive into the target folder.

=item Step 2

t/020-bench/010-hello.t  view on Meta::CPAN

use strict;
use warnings 'all';
use Test::More 'no_plan';
use Time::HiRes 'gettimeofday';
use ASP4::API;
my $api = ASP4::API->new;

ok(1);

{
  my ($time, $persec) = bench('/handlers/dev.simple', 1000);
  warn "\nGET /handlers/dev.simple 1000 times in $time seconds ($persec/second)\n";
}

{
  my ($time, $persec) = bench('/handlers/dev.speed', 1000);
  warn "GET /handlers/dev.speed 1000 times in $time seconds ($persec/second)\n";
}

{
  my ($time, $persec) = bench('/useragent/hello-world.asp', 1000);
  warn "GET /useragent/hello-world.asp 1000 times in $time seconds ($persec/second)\n";
}

{
  my ($time, $persec) = bench('/pageparser/child-inner2.asp', 1000);
  warn "GET /pageparser/child-inner2.asp 1000 times in $time seconds ($persec/second)\n";
}

{
  my ($time, $persec) = bench('/masters/deep.asp', 1000);
  warn "GET /masters/deep.asp 1000 times in $time seconds ($persec/second)\n";
}

sub bench {
  my ($uri, $times) = @_;
  my $start = gettimeofday();
  for( 1..$times ) {
    $api->ua->get($uri)->is_success or die "ERROR";
  }
  
  my $diff = gettimeofday() - $start;
  my $persec = $times / $diff;
  return ($diff, $persec);
}

t/htdocs/masters/deep.asp  view on Meta::CPAN

<%@ Page UseMasterPage="/masters/submaster.asp" %>

<asp:Content PlaceHolderID="meta_title">My Title!</asp:Content>

<asp:Content PlaceHolderID="sub_section">My Content Too!</asp:Content>

t/htdocs/masters/submaster.asp  view on Meta::CPAN

<asp:Content PlaceHolderID="meta_title">Submaster Title</asp:Content>

<asp:Content PlaceHolderID="meta_keywords">submaster keywords</asp:Content>

<asp:Content PlaceHolderID="meta_description">submaster description</asp:Content>

<asp:Content PlaceHolderID="page_heading">The Submaster Page</asp:Content>

<asp:Content PlaceHolderID="page_body">
  The first part.<br/>
  <asp:ContentPlaceHolder id="sub_section">aaa</asp:ContentPlaceHolder>
  The final part.
</asp:Content>



( run in 1.222 second using v1.01-cache-2.11-cpan-39bf76dae61 )