[Catalyst-commits] r7773 - in trunk/examples/Tutorial: .
Final_Tarball Final_Tarballs_Per_Part MyApp MyApp/lib
MyApp/lib/MyApp/Controller MyApp/lib/MyApp/Model
MyApp/lib/MyApp/View MyApp/root/lib/config
MyApp/root/lib/site MyApp/root/src MyApp/root/src/books
MyApp/script MyApp/t
hkclark at dev.catalyst.perl.org
hkclark at dev.catalyst.perl.org
Thu May 22 18:50:05 BST 2008
Author: hkclark
Date: 2008-05-22 18:50:04 +0100 (Thu, 22 May 2008)
New Revision: 7773
Added:
trunk/examples/Tutorial/Final_Tarball/MyApp_Part8.tgz
trunk/examples/Tutorial/Final_Tarballs_Per_Part/
trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part3.tgz
trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part4.tgz
trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part5.tgz
trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part6.tgz
trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part7.tgz
trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part8.tgz
Removed:
trunk/examples/Tutorial/Final_Tarball/MyApp.tgz
Modified:
trunk/examples/Tutorial/MyApp/Changes
trunk/examples/Tutorial/MyApp/Makefile.PL
trunk/examples/Tutorial/MyApp/README
trunk/examples/Tutorial/MyApp/lib/MyApp.pm
trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Books.pm
trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Login.pm
trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Logout.pm
trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Root.pm
trunk/examples/Tutorial/MyApp/lib/MyApp/Model/MyAppDB.pm
trunk/examples/Tutorial/MyApp/lib/MyApp/View/TT.pm
trunk/examples/Tutorial/MyApp/myapp.db
trunk/examples/Tutorial/MyApp/myapp.yml
trunk/examples/Tutorial/MyApp/myapp01.sql
trunk/examples/Tutorial/MyApp/myapp02.sql
trunk/examples/Tutorial/MyApp/myapp03.sql
trunk/examples/Tutorial/MyApp/myappTEST.db
trunk/examples/Tutorial/MyApp/root/lib/config/main
trunk/examples/Tutorial/MyApp/root/lib/site/layout
trunk/examples/Tutorial/MyApp/root/src/books/create_done.tt2
trunk/examples/Tutorial/MyApp/root/src/books/list.tt2
trunk/examples/Tutorial/MyApp/root/src/login.tt2
trunk/examples/Tutorial/MyApp/root/src/ttsite.css
trunk/examples/Tutorial/MyApp/script/myapp_create.pl
trunk/examples/Tutorial/MyApp/script/myapp_fastcgi.pl
trunk/examples/Tutorial/MyApp/script/myapp_server.pl
trunk/examples/Tutorial/MyApp/t/controller_Books.t
trunk/examples/Tutorial/MyApp/t/controller_Logout.t
trunk/examples/Tutorial/MyApp/t/live_app01.t
Log:
Update with "final" code (through Step 8) and "per-part" tarballs that capture ending code for each part along the way. Deleted the old final because that will no longer directly apply because of multiple options for Part 9 (AdvancedCRUD)
Deleted: trunk/examples/Tutorial/Final_Tarball/MyApp.tgz
===================================================================
(Binary files differ)
Added: trunk/examples/Tutorial/Final_Tarball/MyApp_Part8.tgz
===================================================================
(Binary files differ)
Property changes on: trunk/examples/Tutorial/Final_Tarball/MyApp_Part8.tgz
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part3.tgz
===================================================================
(Binary files differ)
Property changes on: trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part3.tgz
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part4.tgz
===================================================================
(Binary files differ)
Property changes on: trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part4.tgz
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part5.tgz
===================================================================
(Binary files differ)
Property changes on: trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part5.tgz
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part6.tgz
===================================================================
(Binary files differ)
Property changes on: trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part6.tgz
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part7.tgz
===================================================================
(Binary files differ)
Property changes on: trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part7.tgz
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part8.tgz
===================================================================
(Binary files differ)
Property changes on: trunk/examples/Tutorial/Final_Tarballs_Per_Part/MyApp_Part8.tgz
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/examples/Tutorial/MyApp/Changes
===================================================================
--- trunk/examples/Tutorial/MyApp/Changes 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/Changes 2008-05-22 17:50:04 UTC (rev 7773)
@@ -1,19 +1,4 @@
This file documents the revision history for Perl extension MyApp.
-0.01 2006-07-07 13:32:13
+0.01 2008-05-21 11:44:15
- initial revision, generated by Catalyst
-
-0.02
- - Part 2: Catalyst Basics
-0.03
- - Part 3: Basic CRUD
-0.04
- - Part 4: Authentication
-0.05
- - Part 5: Authorization
-0.07
- - Part 7: Testing
- - Note: No changes in Part 6: Debugging
-0.08
- - Part 8: Advanced CRUD
-
Modified: trunk/examples/Tutorial/MyApp/Makefile.PL
===================================================================
--- trunk/examples/Tutorial/MyApp/Makefile.PL 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/Makefile.PL 2008-05-22 17:50:04 UTC (rev 7773)
@@ -3,7 +3,7 @@
name 'MyApp';
all_from 'lib/MyApp.pm';
-requires 'Catalyst' => '5.7000';
+requires 'Catalyst::Runtime' => '5.7011';
requires 'Catalyst::Plugin::ConfigLoader';
requires 'Catalyst::Plugin::Static::Simple';
requires 'Catalyst::Action::RenderView';
Modified: trunk/examples/Tutorial/MyApp/README
===================================================================
--- trunk/examples/Tutorial/MyApp/README 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/README 2008-05-22 17:50:04 UTC (rev 7773)
@@ -1 +1,6 @@
Run script/myapp_server.pl to test the application.
+
+
+IMPORTANT NOTE: Because there will be multiple options for Step 9
+(AdvancedCRUD), this directory only contains the complete code through
+Step 8 (Testing).
Modified: trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Books.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Books.pm 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Books.pm 2008-05-22 17:50:04 UTC (rev 7773)
@@ -3,9 +3,7 @@
use strict;
use warnings;
use base 'Catalyst::Controller';
-use FormElementContainer;
-
=head1 NAME
MyApp::Controller::Books - Catalyst Controller
@@ -24,31 +22,33 @@
=cut
sub index : Private {
- my ( $self, $c ) = @_;
+my ( $self, $c ) = @_;
$c->response->body('Matched MyApp::Controller::Books in Books.');
}
-
=head2 list
Fetch all book objects and pass to books/list.tt2 in stash to be displayed
=cut
-
+
sub list : Local {
# Retrieve the usual perl OO '$self' for this object. $c is the Catalyst
# 'Context' that's used to 'glue together' the various components
# that make up the application
my ($self, $c) = @_;
+#$DB::single=1;
+
# Retrieve all of the book records as book model objects and store in the
# stash where they can be accessed by the TT template
- $c->stash->{books} = [$c->model('MyAppDB::Book')->all];
-
+ $c->stash->{books} = [$c->model('MyAppDB::Books')->all];
+
# Set the TT template to use. You will almost always want to do this
- # in your action methods.
+ # in your action methods (actions methods respond to user input in
+ # your controllers).
$c->stash->{template} = 'books/list.tt2';
}
@@ -71,7 +71,7 @@
if ($c->check_user_roles('admin')) {
# Call create() on the book model object. Pass the table
# columns/field values we want to set as hash values
- my $book = $c->model('MyAppDB::Book')->create({
+ my $book = $c->model('MyAppDB::Books')->create({
title => $title,
rating => $rating
});
@@ -118,8 +118,6 @@
}
-
-
=head2 form_create_do
Take information from form and add to database
@@ -135,7 +133,7 @@
my $author_id = $c->request->params->{author_id} || '1';
# Create the book
- my $book = $c->model('MyAppDB::Book')->create({
+ my $book = $c->model('MyAppDB::Books')->create({
title => $title,
rating => $rating,
});
@@ -154,8 +152,6 @@
}
-
-
=head2 delete
Delete a book
@@ -167,13 +163,13 @@
my ($self, $c, $id) = @_;
# Search for the book and then delete it
- $c->model('MyAppDB::Book')->search({id => $id})->delete_all;
+ $c->model('MyAppDB::Books')->search({id => $id})->delete_all;
- # Set a status message to be displayed at the top of the view
- $c->stash->{status_msg} = "Book deleted.";
-
- # Forward to the list action/method in this controller
- $c->forward('list');
+ # Use 'flash' to save information across requests until it's read
+ $c->flash->{status_msg} = "Book deleted";
+
+ # Redirect the user back to the list page
+ $c->response->redirect($c->uri_for('/books/list'));
}
@@ -194,135 +190,9 @@
}
-
-=head2 make_book_widget
-
-Build an HTML::Widget form for book creation and updates
-
-=cut
-
-sub make_book_widget {
- my ($self, $c) = @_;
-
- # Create an HTML::Widget to build the form
- my $w = $c->widget('book_form')->method('post');
-
- # ***New: Use custom class to render each element in the form
- $w->element_container_class('FormElementContainer');
-
- # Get authors
- my @authorObjs = $c->model("MyAppDB::Author")->all();
- my @authors = map {$_->id => $_->last_name }
- sort {$a->last_name cmp $b->last_name} @authorObjs;
-
- # Create the form feilds
- $w->element('Textfield', 'title' )->label('Title')->size(60);
- $w->element('Textfield', 'rating' )->label('Rating')->size(1);
- # Convert to multi-select list
- $w->element('Select', 'authors')->label('Authors')
- ->options(@authors)->multiple(1)->size(3);
- $w->element('Submit', 'submit' )->value('submit');
-
- # Set constraints
- $w->constraint(All => qw/title rating authors/)
- ->message('Required. ');
- $w->constraint(Integer => qw/rating/)
- ->message('Must be an integer. ');
- $w->constraint(Range => qw/rating/)->min(1)->max(5)
- ->message('Must be a number between 1 and 5. ');
- $w->constraint(Length => qw/title/)->min(5)->max(50)
- ->message('Must be between 5 and 50 characters. ');
-
- # Set filters
- for my $column (qw/title rating authors/) {
- $w->filter( HTMLEscape => $column );
- $w->filter( TrimEdges => $column );
- }
-
- # Return the widget
- return $w;
-}
-
-
-
-
-
-=head2 hw_create
-
-Build an HTML::Widget form for book creation and updates
-
-=cut
-
-sub hw_create : Local {
- my ($self, $c) = @_;
-
- # Create the widget and set the action for the form
- my $w = $self->make_book_widget($c);
- $w->action($c->uri_for('hw_create_do'));
-
- # Write form to stash variable for use in template
- $c->stash->{widget_result} = $w->result;
-
- # Set the template
- $c->stash->{template} = 'books/hw_form.tt2';
-}
-
-
-=head2 hw_create_do
-
-Build an HTML::Widget form for book creation and updates
-
-=cut
-
-sub hw_create_do : Local {
- my ($self, $c) = @_;
-
- # Create the widget and set the action for the form
- my $w = $self->make_book_widget($c);
- $w->action($c->uri_for('hw_create_do'));
-
- # Validate the form parameters
- my $result = $w->process($c->req);
-
- # Write form (including validation error messages) to
- # stash variable for use in template
- $c->stash->{widget_result} = $result;
-
- # Were their validation errors?
- if ($result->has_errors) {
- # Warn the user at the top of the form that there were errors.
- # Note that there will also be per-field feedback on
- # validation errors because of '$w->process($c->req)' above.
- $c->stash->{error_msg} = 'Validation errors!';
- } else {
- my $book = $c->model('MyAppDB::Book')->new({});
- $book->populate_from_widget($result);
-
- # Add a record to the join table for this book, mapping to
- # appropriate author. Note that $authors will be 1 author as
- # a scalar or ref to list of authors depending on how many the
- # user selected; the 'ref $authors ?...' handles both cases
- my $authors = $c->request->params->{authors};
- foreach my $author (ref $authors ? @$authors : $authors) {
- $book->add_to_book_authors({author_id => $author});
- }
-
- # Set a status message for the user
- $c->stash->{status_msg} = 'Book created';
-
- # Redisplay an empty form for another
- $c->stash->{widget_result} = $w->result;
- }
-
- # Set the template
- $c->stash->{template} = 'books/hw_form.tt2';
-}
-
-
-
=head1 AUTHOR
-root
+A clever guy
=head1 LICENSE
Modified: trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Login.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Login.pm 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Login.pm 2008-05-22 17:50:04 UTC (rev 7773)
@@ -17,9 +17,8 @@
=cut
+=head2 index
-=head2 index
-
Login logic
=cut
@@ -34,7 +33,8 @@
# If the username and password values were found in form
if ($username && $password) {
# Attempt to log the user in
- if ($c->login($username, $password)) {
+ if ($c->authenticate({ username => $username,
+ password => $password} )) {
# If successful, then let them use the application
$c->response->redirect($c->uri_for('/books/list'));
return;
@@ -49,10 +49,9 @@
}
-
=head1 AUTHOR
-root
+A clever guy
=head1 LICENSE
Modified: trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Logout.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Logout.pm 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Logout.pm 2008-05-22 17:50:04 UTC (rev 7773)
@@ -17,7 +17,6 @@
=cut
-
=head2 index
Logout logic
@@ -35,10 +34,9 @@
}
-
=head1 AUTHOR
-root
+A clever guy
=head1 LICENSE
Modified: trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Root.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Root.pm 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/lib/MyApp/Controller/Root.pm 2008-05-22 17:50:04 UTC (rev 7773)
@@ -42,7 +42,6 @@
sub end : ActionClass('RenderView') {}
-
=head2 auto
Check if there is a user and, if not, forward to login page
@@ -51,11 +50,17 @@
# Note that 'auto' runs after 'begin' but before your actions and that
# 'auto' "chain" (all from application path to most specific class are run)
+# See the 'Actions' section of 'Catalyst::Manual::Intro' for more info.
sub auto : Private {
my ($self, $c) = @_;
- # Allow unauthenticated users to reach the login page
- if ($c->request->path =~ /login/) {
+ # Allow unauthenticated users to reach the login page. This
+ # allows anauthenticated users to reach any action in the Login
+ # controller. To lock it down to a single action, we could use:
+ # if ($c->action eq $c->controller('Login')->action_for('index'))
+ # to only allow unauthenticated access to the C<index> action we
+ # added above.
+ if ($c->controller eq $c->controller('Login')) {
return 1;
}
@@ -77,7 +82,7 @@
=head1 AUTHOR
-root
+Catalyst developer
=head1 LICENSE
Modified: trunk/examples/Tutorial/MyApp/lib/MyApp/Model/MyAppDB.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/MyApp/Model/MyAppDB.pm 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/lib/MyApp/Model/MyAppDB.pm 2008-05-22 17:50:04 UTC (rev 7773)
@@ -5,17 +5,13 @@
my $dsn = $ENV{MYAPP_DSN} ||= 'dbi:SQLite:myapp.db';
__PACKAGE__->config(
- schema_class => 'MyAppDB',
+ schema_class => 'MyApp::Schema::MyAppDB',
connect_info => [
$dsn,
- '',
- '',
- { AutoCommit => 1 },
-
+
],
);
-
=head1 NAME
MyApp::Model::MyAppDB - Catalyst DBIC Schema Model
@@ -25,11 +21,11 @@
=head1 DESCRIPTION
-L<Catalyst::Model::DBIC::Schema> Model using schema L<MyAppDB>
+L<Catalyst::Model::DBIC::Schema> Model using schema L<MyApp::Schema::MyAppDB>
=head1 AUTHOR
-root
+A clever guy
=head1 LICENSE
Modified: trunk/examples/Tutorial/MyApp/lib/MyApp/View/TT.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/MyApp/View/TT.pm 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/lib/MyApp/View/TT.pm 2008-05-22 17:50:04 UTC (rev 7773)
@@ -12,7 +12,7 @@
PRE_PROCESS => 'config/main',
WRAPPER => 'site/wrapper',
ERROR => 'error.tt2',
- TIMER => 0
+ TIMER => 0,
});
=head1 NAME
@@ -29,7 +29,7 @@
=head1 AUTHOR
-root
+A clever guy
=head1 LICENSE
Modified: trunk/examples/Tutorial/MyApp/lib/MyApp.pm
===================================================================
--- trunk/examples/Tutorial/MyApp/lib/MyApp.pm 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/lib/MyApp.pm 2008-05-22 17:50:04 UTC (rev 7773)
@@ -14,31 +14,26 @@
# directory
use Catalyst qw/
- -Debug
- ConfigLoader
+ -Debug
+ ConfigLoader
Static::Simple
-
+
StackTrace
Authentication
- Authentication::Store::DBIC
- Authentication::Credential::Password
Authorization::Roles
Authorization::ACL
Session
Session::Store::FastMmap
Session::State::Cookie
-
- HTML::Widget
/;
+our $VERSION = '0.01';
-our $VERSION = '0.08';
-
# Configure the application.
#
-# Note that settings in MyApp.yml (or other external
+# Note that settings in myapp.yml (or other external
# configuration file that you set up manually) take precedence
# over this when using ConfigLoader. Thus configuration
# details given here can function as a default configuration,
@@ -66,8 +61,6 @@
);
-
-
=head1 NAME
MyApp - Catalyst based application
@@ -86,7 +79,7 @@
=head1 AUTHOR
-root
+Catalyst developer
=head1 LICENSE
Modified: trunk/examples/Tutorial/MyApp/myapp.db
===================================================================
(Binary files differ)
Modified: trunk/examples/Tutorial/MyApp/myapp.yml
===================================================================
--- trunk/examples/Tutorial/MyApp/myapp.yml 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/myapp.yml 2008-05-22 17:50:04 UTC (rev 7773)
@@ -1,36 +1,43 @@
---
name: MyApp
authentication:
- dbic:
- # Note this first definition would be the same as setting
- # __PACKAGE__->config->{authentication}->{dbic}->{user_class} = 'MyAppDB::User'
- # in lib/MyApp.pm (IOW, each hash key becomes a "name:" in the YAML file).
- #
- # This is the model object created by Catalyst::Model::DBIC from your
- # schema (you created 'MyAppDB::User' but as the Catalyst startup
- # debug messages show, it was loaded as 'MyApp::Model::MyAppDB::User').
- # NOTE: Omit 'MyApp::Model' to avoid a component lookup issue in Catalyst 5.66
- user_class: MyAppDB::User
- # This is the name of the field in your 'users' table that contains the user's name
- user_field: username
- # This is the name of the field in your 'users' table that contains the password
- password_field: password
- # Other options can go here for hashed passwords
- # Enabled hashed passwords
- password_type: hashed
- # Use the SHA-1 hashing algorithm
- password_hash_type: SHA-1
-authorization:
- dbic:
- # This is the model object created by Catalyst::Model::DBIC from your
- # schema (you created 'MyAppDB::Role' but as the Catalyst startup
- # debug messages show, it was loaded as 'MyApp::Model::MyAppDB::Role').
- # NOTE: Omit 'MyApp::Model' to avoid a component lookup issue in Catalyst 5.66
- role_class: MyAppDB::Role
- # The name of the field in the 'roles' table that contains the role name
- role_field: role
- # The name of the accessor used to map a role to the users who have this role
- # See the has_many() in MyAppDB/Role.pm
- role_rel: map_user_role
- # The name of the field in the user_role table that references the user
- user_role_user_field: user_id
+ default_realm: dbic
+ realms:
+ dbic:
+ credential:
+ # Note this first definition would be the same as setting
+ # __PACKAGE__->config->{authentication}->{realms}->{dbic}
+ # ->{credential} = 'Password' in lib/MyApp.pm
+ # (IOW, each hash key becomes a "name:" in the YAML file).
+ #
+ # Specify that we are going to do password-based auth
+ class: Password
+ # This is the name of the field in the users table with the
+ # password stored in it
+ password_field: password
+ # We are using an unencrypted password now
+ password_type: hashed
+ # Use the SHA-1 hashing algorithm
+ password_hash_type: SHA-1
+ store:
+ # Use DBIC to retrieve username, password & role information
+ class: DBIx::Class
+ # This is the model object created by Catalyst::Model::DBIC
+ # from your schema (you created 'MyAppDB::User' but as the
+ # Catalyst startup debug messages show, it was loaded as
+ # 'MyApp::Model::MyAppDB::Users').
+ # NOTE: Omit 'MyApp::Model' here just as you would when using
+ # '$c->model("MyAppDB::Users)'
+ user_class: MyAppDB::Users
+ # This is the name of the field in your 'users' table that
+ # contains the user's name
+ id_field: username
+ # This is the name of a many_to_many relation in the users
+ # object that points to the roles for that user
+ role_relation: roles
+ # This is the name of field in the roles table that contains
+ # the role information
+ role_field: role
+
+session:
+ flash_to_stash: 1
Modified: trunk/examples/Tutorial/MyApp/myapp01.sql
===================================================================
--- trunk/examples/Tutorial/MyApp/myapp01.sql 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/myapp01.sql 2008-05-22 17:50:04 UTC (rev 7773)
@@ -31,7 +31,7 @@
INSERT INTO authors VALUES (4, 'Richard', 'Stevens');
INSERT INTO authors VALUES (5, 'Douglas', 'Comer');
INSERT INTO authors VALUES (6, 'Tom', 'Christiansen');
-INSERT INTO authors VALUES (7, ' Nathan', 'Torkington');
+INSERT INTO authors VALUES (7, 'Nathan', 'Torkington');
INSERT INTO authors VALUES (8, 'Jeffrey', 'Zeldman');
INSERT INTO book_authors VALUES (1, 1);
INSERT INTO book_authors VALUES (1, 2);
@@ -41,3 +41,4 @@
INSERT INTO book_authors VALUES (4, 6);
INSERT INTO book_authors VALUES (4, 7);
INSERT INTO book_authors VALUES (5, 8);
+
Modified: trunk/examples/Tutorial/MyApp/myapp02.sql
===================================================================
--- trunk/examples/Tutorial/MyApp/myapp02.sql 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/myapp02.sql 2008-05-22 17:50:04 UTC (rev 7773)
@@ -31,3 +31,4 @@
INSERT INTO user_roles VALUES (1, 2);
INSERT INTO user_roles VALUES (2, 1);
INSERT INTO user_roles VALUES (3, 1);
+
Modified: trunk/examples/Tutorial/MyApp/myapp03.sql
===================================================================
--- trunk/examples/Tutorial/MyApp/myapp03.sql 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/myapp03.sql 2008-05-22 17:50:04 UTC (rev 7773)
@@ -4,3 +4,4 @@
UPDATE users SET password = 'e727d1464ae12436e899a726da5b2f11d8381b26' WHERE id = 1;
UPDATE users SET password = 'e727d1464ae12436e899a726da5b2f11d8381b26' WHERE id = 2;
UPDATE users SET password = 'e727d1464ae12436e899a726da5b2f11d8381b26' WHERE id = 3;
+
Modified: trunk/examples/Tutorial/MyApp/myappTEST.db
===================================================================
(Binary files differ)
Modified: trunk/examples/Tutorial/MyApp/root/lib/config/main
===================================================================
--- trunk/examples/Tutorial/MyApp/root/lib/config/main 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/root/lib/config/main 2008-05-22 17:50:04 UTC (rev 7773)
@@ -13,7 +13,7 @@
# define a data structure to hold sitewide data
site = {
title => 'Catalyst::View::TTSite Example Page',
- copyright => '2006 Your Name Here',
+ copyright => '2008 Your Name Here',
};
# load up any other configuration items
Modified: trunk/examples/Tutorial/MyApp/root/lib/site/layout
===================================================================
--- trunk/examples/Tutorial/MyApp/root/lib/site/layout 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/root/lib/site/layout 2008-05-22 17:50:04 UTC (rev 7773)
@@ -7,5 +7,3 @@
</div>
<div id="footer">[% PROCESS site/footer %]</div>
-
-
Modified: trunk/examples/Tutorial/MyApp/root/src/books/create_done.tt2
===================================================================
--- trunk/examples/Tutorial/MyApp/root/src/books/create_done.tt2 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/root/src/books/create_done.tt2 2008-05-22 17:50:04 UTC (rev 7773)
@@ -32,4 +32,4 @@
<pre>
Dump of the 'book' variable:
[% Dumper.dump(book) %]
-</pre>
+
Modified: trunk/examples/Tutorial/MyApp/root/src/books/list.tt2
===================================================================
--- trunk/examples/Tutorial/MyApp/root/src/books/list.tt2 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/root/src/books/list.tt2 2008-05-22 17:50:04 UTC (rev 7773)
@@ -16,13 +16,16 @@
<td>
[% # First initialize a TT variable to hold a list. Then use a TT FOREACH -%]
[% # loop in 'side effect notation' to load just the last names of the -%]
- [% # authors into the list. Note that we are making a bogus assignment to -%]
- [% # the 'xx' vbl to avoid printing the size of the list after each push. -%]
+ [% # authors into the list. Note that the 'push' TT vmethod does not -%]
+ [% # a value, so nothing will be printed here. But, if you have something -%]
+ [% # in TT that does return a method and you don't want it printed, you -%]
+ [% # can: 1) assign it to a bogus value, or 2) use the CALL keyword to -%]
+ [% # call it and discard the return value. -%]
[% tt_authors = [ ];
- xx = tt_authors.push(author.last_name) FOREACH author = book.authors %]
- [% # Now use a TT 'virtual method' to display the author count -%]
+ tt_authors.push(author.last_name) FOREACH author = book.authors %]
+ [% # Now use a TT 'virtual method' to display the author count in parens -%]
([% tt_authors.size %])
- [% # Use another TT virtual method to join the names with comma separators -%]
+ [% # Use another TT vmethod to join & print the names & comma separators -%]
[% tt_authors.join(', ') %]
</td>
<td>
@@ -59,11 +62,3 @@
<a href="[% Catalyst.uri_for('form_create') %]">Create</a>
[% END %]
</p>
-
-<p>
- HTML::Widget:
- <a href="[% Catalyst.uri_for('hw_create') %]">Create</a>
- <a href="[% Catalyst.uri_for('hw_update') %]">Update</a>
-</p>
-
-
Modified: trunk/examples/Tutorial/MyApp/root/src/login.tt2
===================================================================
--- trunk/examples/Tutorial/MyApp/root/src/login.tt2 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/root/src/login.tt2 2008-05-22 17:50:04 UTC (rev 7773)
@@ -22,7 +22,7 @@
# This code illustrates how certain parts of the TT
# template will only be shown to users who have logged in
%]
-[% IF Catalyst.user %]
+[% IF Catalyst.user_exists %]
Please Note: You are already logged in as '[% Catalyst.user.username %]'.
You can <a href="[% Catalyst.uri_for('/logout') %]">logout</a> here.
[% ELSE %]
@@ -35,3 +35,4 @@
TT code, it's probably a little too subtle for use in "normal"
comments.
%]
+</p>
Modified: trunk/examples/Tutorial/MyApp/root/src/ttsite.css
===================================================================
--- trunk/examples/Tutorial/MyApp/root/src/ttsite.css 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/root/src/ttsite.css 2008-05-22 17:50:04 UTC (rev 7773)
@@ -43,26 +43,3 @@
.error {
color: [% site.col.error %];
}
-
-label {
- display: block;
- width: 10em;
- position: relative;
- margin: .5em 0em;
-}
-label input {
- position: absolute;
- left: 100%;
-}
-label select {
- position: absolute;
- left: 100%;
-}
-.submit {
- margin-top: 2em;;
-}
-.error_messages {
- color: [% site.col.error %];
-}
-
-
Modified: trunk/examples/Tutorial/MyApp/script/myapp_create.pl
===================================================================
--- trunk/examples/Tutorial/MyApp/script/myapp_create.pl 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/script/myapp_create.pl 2008-05-22 17:50:04 UTC (rev 7773)
@@ -39,6 +39,7 @@
Examples:
myapp_create.pl controller My::Controller
+ myapp_create.pl controller My::Controller BindLex
myapp_create.pl -mechanize controller My::Controller
myapp_create.pl view My::View
myapp_create.pl view MyView TT
Modified: trunk/examples/Tutorial/MyApp/script/myapp_fastcgi.pl
===================================================================
--- trunk/examples/Tutorial/MyApp/script/myapp_fastcgi.pl 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/script/myapp_fastcgi.pl 2008-05-22 17:50:04 UTC (rev 7773)
@@ -11,7 +11,7 @@
use MyApp;
my $help = 0;
-my ( $listen, $nproc, $pidfile, $manager, $detach );
+my ( $listen, $nproc, $pidfile, $manager, $detach, $keep_stderr );
GetOptions(
'help|?' => \$help,
@@ -20,6 +20,7 @@
'pidfile|p=s' => \$pidfile,
'manager|M=s' => \$manager,
'daemon|d' => \$detach,
+ 'keeperr|e' => \$keep_stderr,
);
pod2usage(1) if $help;
@@ -30,6 +31,7 @@
pidfile => $pidfile,
manager => $manager,
detach => $detach,
+ keep_stderr => $keep_stderr,
}
);
@@ -58,6 +60,8 @@
-M -manager specify alternate process manager
(FCGI::ProcManager sub-class)
or empty string to disable
+ -e -keeperr send error messages to STDOUT, not
+ to the webserver
=head1 DESCRIPTION
Modified: trunk/examples/Tutorial/MyApp/script/myapp_server.pl
===================================================================
--- trunk/examples/Tutorial/MyApp/script/myapp_server.pl 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/script/myapp_server.pl 2008-05-22 17:50:04 UTC (rev 7773)
@@ -2,7 +2,8 @@
BEGIN {
$ENV{CATALYST_ENGINE} ||= 'HTTP';
- $ENV{CATALYST_SCRIPT_GEN} = 28;
+ $ENV{CATALYST_SCRIPT_GEN} = 30;
+ require Catalyst::Engine::HTTP;
}
use strict;
@@ -16,9 +17,9 @@
my $fork = 0;
my $help = 0;
my $host = undef;
-my $port = 3000;
+my $port = $ENV{MYAPP_PORT} || $ENV{CATALYST_PORT} || 3000;
my $keepalive = 0;
-my $restart = 0;
+my $restart = $ENV{MYAPP_RELOAD} || $ENV{CATALYST_RELOAD} || 0;
my $restart_delay = 1;
my $restart_regex = '\.yml$|\.yaml$|\.pm$';
my $restart_directory = undef;
@@ -40,7 +41,7 @@
pod2usage(1) if $help;
-if ( $restart ) {
+if ( $restart && $ENV{CATALYST_ENGINE} eq 'HTTP' ) {
$ENV{CATALYST_ENGINE} = 'HTTP::Restarter';
}
if ( $debug ) {
Modified: trunk/examples/Tutorial/MyApp/t/controller_Books.t
===================================================================
--- trunk/examples/Tutorial/MyApp/t/controller_Books.t 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/t/controller_Books.t 2008-05-22 17:50:04 UTC (rev 7773)
@@ -5,6 +5,6 @@
BEGIN { use_ok 'Catalyst::Test', 'MyApp' }
BEGIN { use_ok 'MyApp::Controller::Books' }
-ok( request('/books')->is_success, 'Request should succeed' );
+ok( request('/books')->is_redirect, 'Request should succeed' );
Modified: trunk/examples/Tutorial/MyApp/t/controller_Logout.t
===================================================================
--- trunk/examples/Tutorial/MyApp/t/controller_Logout.t 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/t/controller_Logout.t 2008-05-22 17:50:04 UTC (rev 7773)
@@ -5,6 +5,6 @@
BEGIN { use_ok 'Catalyst::Test', 'MyApp' }
BEGIN { use_ok 'MyApp::Controller::Logout' }
-ok( request('/logout')->is_success, 'Request should succeed' );
+ok( request('/logout')->is_redirect, 'Request should succeed' );
Modified: trunk/examples/Tutorial/MyApp/t/live_app01.t
===================================================================
--- trunk/examples/Tutorial/MyApp/t/live_app01.t 2008-05-22 17:35:28 UTC (rev 7772)
+++ trunk/examples/Tutorial/MyApp/t/live_app01.t 2008-05-22 17:50:04 UTC (rev 7773)
@@ -27,13 +27,19 @@
$_->get_ok("http://localhost/", "Check redirect of base URL") for $ua1, $ua2;
# Use title_is() to check the contents of the <title>...</title> tags
$_->title_is("Login", "Check for login title") for $ua1, $ua2;
-# Use content_contains() to match on test in the html body
+# Use content_contains() to match on text in the html body
$_->content_contains("You need to log in to use this application",
"Check we are NOT logged in") for $ua1, $ua2;
# Log in as each user
+# Specify username and password on the URL
$ua1->get_ok("http://localhost/login?username=test01&password=mypass", "Login 'test01'");
-$ua2->get_ok("http://localhost/login?username=test02&password=mypass", "Login 'test02'");
+# Use the form for user 'test02'; note there is no description here
+$ua2->submit_form(
+ fields => {
+ username => 'test02',
+ password => 'mypass',
+ });
# Go back to the login page and it should show that we are already logged in
$_->get_ok("http://localhost/login", "Return to '/login'") for $ua1, $ua2;
@@ -41,7 +47,7 @@
$_->content_contains("Please Note: You are already logged in as ",
"Check we ARE logged in" ) for $ua1, $ua2;
-# 'Click' the 'Logout' link
+# 'Click' the 'Logout' link (see also 'text_regex' and 'url_regex' options)
$_->follow_link_ok({n => 1}, "Logout via first link on page") for $ua1, $ua2;
$_->title_is("Login", "Check for login title") for $ua1, $ua2;
$_->content_contains("You need to log in to use this application",
@@ -89,10 +95,9 @@
$ua1->get_ok($delLinks[$#delLinks]->url, 'Delete last book');
# Check that delete worked
$ua1->content_contains("Book List", "Book List page test");
-$ua1->content_contains("Book deleted.", "Book was deleted");
+$ua1->content_contains("Book deleted", "Book was deleted");
# User 'test02' should not be able to add a book
$ua2->get_ok("http://localhost/books/url_create/TestTitle2/2/5", "'test02' add");
$ua2->content_contains("Unauthorized!", "Check 'test02' cannot add");
-
More information about the Catalyst-commits
mailing list