ASP4
view release on metacpan or search on metacpan
sbin/asphelper view on Meta::CPAN
$appName\::db::model - Base class for all $appName entity classes.
\=head1 SYNOPSIS
# In your class:
package $appName\::db::thing;
use strict;
use warnings 'all';
use base '$appName\::db::model';
__PACKAGE__->set_up_table('things');
1;# return true:
\=head1 DESCRIPTION
This module was generated by $0 on @{[ scalar(localtime()) ]}.
B<***IT IS SAFE to make changes to this file, as it will not be overwritten.***>.
\=head1 SEE ALSO
L<Class::DBI::Lite>
\=cut
CODE
close($ofh);
}# end unless()
}# end if()
unless( -f "www/t/010-basic/010-compile.t" )
{
warn "www/t/010-basic/010-compile.t\n";
open my $ofh, '>', "www/t/010-basic/010-compile.t"
or die "Cannot open 'www/t/010-basic/010-compile.t' for writing: $!";
print $ofh <<"TEST";
#!/usr/bin/perl -w
use strict;
use warnings 'all';
use Test::More 'no_plan';
use ASP4::API;
my \$api = ASP4::API->new;
TEST
if( $CDBIL_Version )
{
print $ofh <<"MORE";
@{[ $dbName ? qq(use_ok('$appName\::db::model');) : '' ]}
MORE
}# end if()
print $ofh <<"TEST";
my \$res = \$api->ua->post("/handlers/$hClass.www.echo", {
hello => "world"
});
like \$res->content, qr('hello'\\s+\\=\>\\s+'world'), "/handlers/$hClass.www.echo?hello=world works";
ok( \$res = \$api->ua->get("/"), "Got '/'.");
ok( \$res->is_success, "GET / is successful.");
ok( \$res->content, "Got some content also.");
TEST
if( $dbName && $dbUser )
{
print $ofh <<"TEST";
for( 0..10 )
{
like \$res->content, qr(visited this page \$_ time), "Simple session counter: \$_ visits recorded.";
\$res = \$api->ua->get("/");
}# end for()
TEST
}# end if()
print $ofh <<"TEST";
# More tests can go here or in other files.
TEST
close($ofh);
}# end unless()
warn "="x60, "\n";
warn " Running Initial Test Suite...\n";
warn "="x60, "\n";
chdir("www");
`asp4 /` =~ m{You have visited this page}
or die "Warning: ASP script contents (/index.asp) not what we expected!";
system("prove -rv t");
# Talk about the config now:
warn <<"END";
!!!!!!!!!!!!!!!!!!!!!! CONGRATULATIONS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*** Update your Apache Config ***
Include $cwd/www/conf/httpd.conf
*** Add This to your /etc/hosts File ***
127.0.0.1 $domain
*** Restart Apache ***
Maybe: sudo /etc/init.d/httpd restart
Or: sudo /etc/init.d/apache2 restart
Or: service apache2 restart
*** To Test it in Your Browser ***
Navigate to http://$domain
*** To Run the Unit Tests ***
cd $cwd/www
prove -rv t
*** To Run an ASP Script From the Command Line ***
cd $cwd/www
asp4 /index.asp
END
sub generic_config
{
my ($has_db) = @_;
my $str = <<'EOF';
{
"system": {
"post_processors": [
],
"libs": [
"@ServerRoot@/lib",
"@ProjectRoot@/common/lib"
],
"load_modules": [
],
"env_vars": {
},
"settings": {
}
},
"errors": {
"error_handler": "ASP4::ErrorHandler",
"mail_errors_to": "%email%",
"mail_errors_from": "root@localhost",
"smtp_server": "localhost"
},
"web": {
"application_name": "%appName%",
"application_root": "@ServerRoot@",
"www_root": "@ServerRoot@/htdocs",
"handler_root": "@ServerRoot@/handlers",
"page_cache_root": "/tmp/PAGE_CACHE",
"handler_resolver": "ASP4::HandlerResolver",
"handler_runner": "ASP4::HandlerRunner",
"filter_resolver": "ASP4::FilterResolver",
"request_filters": [
],
"routes": [
],
"disable_persistence": [
]
},
"data_connections": {
EOF
if( $has_db )
{
$str .= <<'EOF';
"session": {
"manager": "ASP4::SessionStateManager",
"cookie_name": "session-id",
"cookie_domain": "*",
"session_timeout": "*",
"dsn": "DBI:mysql:%dbName%:%dbHost%",
"username": "%dbUser%",
"password": "%dbPass%"
},
"main": {
"dsn": "DBI:mysql:%dbName%:%dbHost%",
"username": "%dbUser%",
"password": "%dbPass%"
}
EOF
}
else
{
$str .= <<'EOF';
"session": {
( run in 0.513 second using v1.01-cache-2.11-cpan-ceb78f64989 )