Add regex test case to Testing.
Run spellcheck.
Fix typo in footer.
Update svn checkout commands to use tags.
Add redisplay of cleared form in last section of Advanced CRUD.
Fix POD for Login & Logout.
Update screenshot of dev svr log output.
Misc small fixes.
Kennedy Clark, C<hkclark@gmail.com>
Please report any errors, issues or suggestions to the author. The
-most recent version of the Catlayst Tutorial can be found at
+most recent version of the Catalyst Tutorial can be found at
L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Runtime/lib/Catalyst/Manual/Tutorial/>.
Copyright 2006, Kennedy Clark, under Creative Commons License
Kennedy Clark, C<hkclark@gmail.com>
Please report any errors, issues or suggestions to the author. The
-most recent version of the Catlayst Tutorial can be found at
+most recent version of the Catalyst Tutorial can be found at
L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Runtime/lib/Catalyst/Manual/Tutorial/>.
Copyright 2006, Kennedy Clark, under Creative Commons License
pulled from the Catalyst Subversion repository in one step with the
following command:
- svn checkout http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial -r 4627 .
+ svn co http://dev.catalyst.perl.org/repos/Catalyst/tags/examples/Tutorial/MyApp/5.7/AdvancedCRUD MyApp
=head1 C<HTML::WIDGET> FORM CREATION
return $w;
}
-This method provides a central location that builds an HTML::Widget-
-based form with the appropriate fields. The "Get Authors" code uses
-DBIC to retrieve a list of model objects and then uses C<map> to create
-a hash where the hash keys are the database primary keys from the
-authors table and the associated values are the last names of the
+This method provides a central location that builds an
+HTML::Widget-based form with the appropriate fields. The "Get authors"
+code uses DBIC to retrieve a list of model objects and then uses C<map>
+to create a hash where the hash keys are the database primary keys from
+the authors table and the associated values are the last names of the
authors.
=head2 Add Actions to Display and Save the Form
# 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
single call to C<$book-E<gt>populate_from_widget>. Note that we still
have to call C<$book-E<gt>add_to_book_authors> once per author because
C<populate_from_widget> does not currently handle the relationships
-between tables.
+between tables. Also, we reset the form to an empty fields by adding
+another call to C<$w-E<gt>result> and storing the output in the stash
+(if we don't override the output from C<$w-E<gt>process($c-E<gt>req)>,
+the form values already entered will be retained on redisplay --
+although this could be desirable for some applications, we avoid it
+here to help avoid the creation of duplicate records).
=head2 Try Out the Form
Some developers my wish to use the "old-fashioned" table style of
rendering a form in lieu of the default C<HTML::Widget> rendering that
-assumes you will use CSS for formatting.
+assumes you will use CSS for formatting. This section demonstrates
+some techniques that can override the default rendering with a
+custom class.
=head2 Add a New "Element Container"
=item *
-JavaScript to position the user's curson in the first field of the form.
+JavaScript to position the user's cursor in the first field of the form.
=back
Kennedy Clark, C<hkclark@gmail.com>
Please report any errors, issues or suggestions to the author. The
-most recent version of the Catlayst Tutorial can be found at
+most recent version of the Catalyst Tutorial can be found at
L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Runtime/lib/Catalyst/Manual/Tutorial/>.
Copyright 2006, Kennedy Clark, under Creative Commons License
=head2 "Un-indenting" with Emacs
-Although there author has not used emacs for many years (appologies to
+Although there author has not used emacs for many years (apologies to
the emacs fans out there), here is a quick hint to get you started. To
replace the leading spaces of every line in a file, use:
Kennedy Clark, C<hkclark@gmail.com>
Please report any errors, issues or suggestions to the author. The
-most recent version of the Catlayst Tutorial can be found at
+most recent version of the Catalyst Tutorial can be found at
L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Runtime/lib/Catalyst/Manual/Tutorial/>.
Copyright 2006, Kennedy Clark, under Creative Commons License
=item 9
-L<Appendices|Catalyst::Manual::Tutorial::Appendicies>
+L<Appendices|Catalyst::Manual::Tutorial::Appendices>
=back
pulled from the Catalyst Subversion repository in one step with the
following command:
- svn checkout http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial -r 4612 .
+ svn co http://dev.catalyst.perl.org/repos/Catalyst/tags/examples/Tutorial/MyApp/5.7/Authentication MyApp
=head1 BASIC AUTHENTICATION
Then update it to match:
- =head2 base
+ =head2 index
Login logic
modifier -- this forces the match on I<only> C</login>, not
C</login/somethingelse>.
-Next, create a corresponding method in C<lib/MyApp/Controller/Logout.pm>:
+Next, update the corresponding method in C<lib/MyApp/Controller/Logout.pm>
+to match:
- =head2 base
+ =head2 index
Logout logic
Kennedy Clark, C<hkclark@gmail.com>
Please report any errors, issues or suggestions to the author. The
-most recent version of the Catlayst Tutorial can be found at
+most recent version of the Catalyst Tutorial can be found at
L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Runtime/lib/Catalyst/Manual/Tutorial/>.
Copyright 2006, Kennedy Clark, under Creative Commons License
pulled from the Catalyst Subversion repository in one step with the
following command:
- svn checkout http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial -r 4613 .
+ svn co http://dev.catalyst.perl.org/repos/Catalyst/tags/examples/Tutorial/MyApp/5.7/Authorization MyApp
=head1 BASIC AUTHORIZATION
Kennedy Clark, C<hkclark@gmail.com>
Please report any errors, issues or suggestions to the author. The
-most recent version of the Catlayst Tutorial can be found at
+most recent version of the Catalyst Tutorial can be found at
L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Runtime/lib/Catalyst/Manual/Tutorial/>.
Copyright 2006, Kennedy Clark, under Creative Commons License
=item 9
-L<Appendicies|Catalyst::Manual::Tutorial::Appendicies>
+L<Appendices|Catalyst::Manual::Tutorial::Appendices>
=back
pulled from the Catalyst Subversion repository in one step with the
following command:
- svn checkout http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial -r 4611 .
+ svn co http://dev.catalyst.perl.org/repos/Catalyst/tags/examples/Tutorial/5.7X/BasicCRUD MyApp
=head1 FORMLESS SUBMISSION
[% # simple strings (e.g., no variable interpolation). -%]
[% META title = 'Book Created' %]
- [% # Output information about the record that was added. Note use -%]
- [% # of 'first' to only list the first author (if > 1 author). TT -%]
- [% # v2.15 has an issue that requires -%]
- [% # 'book.authors.list.first.value.last_name' vs. the shorter -%]
- [% # 'book.authors.first.last_name' in prior versions. -%]
- <p>Added book '[% book.title %]'
- by '[% book.authors.list.first.value.last_name %]'
+ [% # Output information about the record that was added. First title. -%]
+ <p>Added book '[% book.title %]'
+
+ [% # Output the last name of the first author. This is complicated by an -%]
+ [% # issue in TT 2.15 where blessed hash objects are not handled right. -%]
+ [% # First, fetch 'book.authors' from the DB once. -%]
+ [% authors = book.authors %]
+ [% # Now use IF statements to test if 'authors.first' is "working". If so, -%]
+ [% # we use it. Otherwise we use a hack that seems to keep TT 2.15 happy. -%]
+ by '[% authors.first.last_name IF authors.first;
+ authors.list.first.value.last_name IF ! authors.first %]'
+
+ [% # Output the rating for the book that was added -%]
with a rating of [% book.rating %].</p>
[% # Provide a link back to the list page -%]
=head2 Add Method to Process Form Values and Update Database
Edit C<lib/MyApp/Controller/Books.pm> and add the following method to
-save the form information to the databse:
+save the form information to the database:
=head2 form_create_do
Kennedy Clark, C<hkclark@gmail.com>
Please report any errors, issues or suggestions to the author. The
-most recent version of the Catlayst Tutorial can be found at
+most recent version of the Catalyst Tutorial can be found at
L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Runtime/lib/Catalyst/Manual/Tutorial/>.
Copyright 2006, Kennedy Clark, under Creative Commons License
=item 9
-L<Appendices|Catalyst::Manual::Tutorial::Appendicies>
+L<Appendices|Catalyst::Manual::Tutorial::Appendices>
=back
pulled from the Catalyst Subversion repository in one step with the
following command:
- svn checkout http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial -r 4609 .
+ svn co http://dev.catalyst.perl.org/repos/Catalyst/tags/examples/Tutorial/MyApp/5.7/CatalystBasics MyApp
=head1 CREATE A CATALYST PROJECT
following should be appended to the logging output of the development
server:
- [info] *** Request 1 (0.008/s) [2822] [Mon Jul 3 12:42:43 2006] ***
+ [info] *** Request 1 (0.043/s) [6003] [Fri Jul 7 13:32:53 2006] ***
[debug] "GET" request for "/" from "127.0.0.1"
- [info] Request took 0.154781s (6.461/s)
+ [info] Request took 0.067675s (14.777/s)
.----------------------------------------------------------------+-----------.
| Action | Time |
+----------------------------------------------------------------+-----------+
- | /default | 0.069475s |
- | /end | 0.085305s |
+ | /default | 0.002844s |
+ | /end | 0.000207s |
'----------------------------------------------------------------+-----------'
Press Ctrl-C to break out of the development server.
Kennedy Clark, C<hkclark@gmail.com>
Please report any errors, issues or suggestions to the author. The
-most recent version of the Catlayst Tutorial can be found at
+most recent version of the Catalyst Tutorial can be found at
L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Runtime/lib/Catalyst/Manual/Tutorial/>.
Copyright 2006, Kennedy Clark, under Creative Commons License
Kennedy Clark, C<hkclark@gmail.com>
Please report any errors, issues or suggestions to the author. The
-most recent version of the Catlayst Tutorial can be found at
+most recent version of the Catalyst Tutorial can be found at
L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Runtime/lib/Catalyst/Manual/Tutorial/>.
Copyright 2006, Kennedy Clark, under Creative Commons License
Kennedy Clark, C<hkclark@gmail.com>
Please report any errors, issues or suggestions to the author. The
-most recent version of the Catlayst Tutorial can be found at
+most recent version of the Catalyst Tutorial can be found at
L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Runtime/lib/Catalyst/Manual/Tutorial/>.
Copyright 2006, Kennedy Clark, under Creative Commons License
pulled from the Catalyst Subversion repository in one step with the
following command:
- svn checkout http://dev.catalyst.perl.org/repos/Catalyst/trunk/examples/Tutorial -r 4614 .
+ svn co http://dev.catalyst.perl.org/repos/Catalyst/tags/examples/Tutorial/MyApp/5.7/Testing MyApp
=head1 RUNNING THE "CANNED" CATALYST TESTS
$ua1->title_is("Book Created", "Book created title");
$ua1->content_contains("Added book 'TestTitle'", "Check title added OK");
$ua1->content_contains("by 'Stevens'", "Check author added OK");
- $ua1->content_contains("a rating of 2.", "Check rating added");
+ $ua1->content_contains("with a rating of 2.", "Check rating added");
+ # Try a regular expression to combine the previous 3 checks & account for whitespace
+ $ua1->content_like(qr/Added book 'TestTitle'\s+by 'Stevens'\s+with a rating of 2./, "Regex check");
# Make sure the new book shows in the list
$ua1->get_ok("http://localhost/books/list", "'test01' book list");
Kennedy Clark, C<hkclark@gmail.com>
Please report any errors, issues or suggestions to the author. The
-most recent version of the Catlayst Tutorial can be found at
+most recent version of the Catalyst Tutorial can be found at
L<http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Runtime/lib/Catalyst/Manual/Tutorial/>.
Copyright 2006, Kennedy Clark, under Creative Commons License