Errata for [[../TheBook]]
=========================
## General notes
Throughout the book, [% Catalyst.method_name %] is used in the templates because the book used an old version of the TTSite helper; with the latest version, you need [% c.method_name %].
[% Catalyst.uri_for("person/edit", "$person.id") %] is poor practice; the correct approach is to use the action object form - [% c.uri_for(c.controller('Person').action_for('edit'), person.id) %]
Catalyst::Controller::BindLex is deprecated and unmaintained; you need to use $c->stash and $c->session normally instead of :Stash and friends.[E20-361](http://www.a1certifications.com/E20-361.html)
Catalyst::Controller::BindLex is deprecated and unmaintained; you need to use $c->stash and $c->session normally instead of :Stash and friends.
DBIx::Class::ResultSetManager was always experimental and is now scheduled to be deleted; instead, write a resultset class normally (you may wish to look at [load_namespaces()](http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/Schema.pm#load_namespaces) in [DBIx::Class::Schema](http://search.cpan.org/perldoc?DBIx::Class::Schema) to make this easier).
If you are using [Catalyst::Model::DBIC::Schema](http://search.cpan.org/perldoc?Catalyst::Model::DBIC::Schema) 0.22 or newer the generate classes will be set up to work with ResultSet classes as recommended above. Those generate classes are also set up to use Result classes, this means that in the places where the book tells you to add something like
`__PACKAGE__->belongs_to( person => 'AddressBook::Schema::AddressDB::People' );`
you should add
`__PACKAGE__->belongs_to( person => 'AddressBook::Schema::AddressDB::Result::People' );`
instead. As a [ruch concerts](http://www.onlineticketspot.com/concerts/Rush.php)
instead. As a general guide, anywhere the book tells you to use `AppName::Schema::Something::SomethingElse` you should use `AppName::Schema::Something::Result::SomethingElse` instead. That is, replace the last `::` with `::Result::`.
general guide, anywhere the book tells you to use `AppName::Schema::Something::SomethingElse` you should use `AppName::Schema::Something::Result::SomethingElse` instead. That is, replace the last `::` with `::Result::`.
You can determine the version of [Catalyst::Model::DBIC::Schema](http://search.cpan.org/perldoc?Catalyst::Model::DBIC::Schema) you have installed by running `perl -MCatalyst::Model::DBIC::Schema -le 'print $Catalyst::Model::DBIC::Schema::VERSION'`
CGI::FormBuilder is limited and the maintainer no longer uses perl; you should look at HTML::FormFu instead.
## Chapter 2
* On page 22, there is an unnecessary space between the quote and http
in "xmlns=" http://..."
* On page 22, "html://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> only needs to appear once.
* Page 24, "...in Hello' to the browser." 'browser' should be 'development server output'.
* On page 27, "$c->forward('View::TT');$c->forward('View::TT');" should read "$c->forward('View::TT');"
* On page 28, the "\" characters are meant to be continuations of the command-line across newlines. The newlines were omitted, so you should also omit the "\" characters.
## Chapter 3
* On pages 34, if your People.pm and Addresses.pm files are now in Schema/AddressDB/Result then inspect the first line of these files. Noting the difference from the book, similarly modify the code you add in on pages 35 & 36. This from Catalyst 5.7014 ?
* On page 37, multiple leading slash (/) characters need to be removed.
* On page 39, leading slash (/) needs to be removed from 'The code in /lib/AddressBook...'
* On page 41, and throughout the book, the usage of [% Catalyst.uri_for("person/edit/$person.id") %] etc. is incorrect, see perldoc Catalyst. [% Catalyst.uri_for("person/edit", "$person.id") %] seems to be correct. You can probably ignore this unless you start putting unicode into the $path argument.
* On page 44, lower case c in 'Catalyst::controller::FormBuilder' should be upper case.
* On page 44, unfortunate line break on path: '/person/edit'
* On page 44, leading slash (/) needs to be removed from '/root/forms/person/edit.fb' and from '/root/src/person/edit.tt2'
* On page 47, the indentation of edit.fb must be maintained as shown, if you cut and paste from the ebook you will not get the correct indentation because the indentation on page 48 does not match that on page 47. Look at the example for the person/edit.fb on page 44 to see how. Incorrect indentation will foul up the form display in your browser and data will not be saved.
* On page 48, remove the "'" from "...BindLex')"
* In the code examples on pages 44, 45 and 49, "`$c->form`" should read
"`$self->formbuilder`" throughout, and the TT code should say "[% Form<nop>Builder.render %]" instead of "`[% form.render %]`".
(This problem is fixed in the rest of the Form<nop>Builder code, not sure how it got into Chapter 3.)
* On page 55, current versions of Catalyst use a .conf file. In order to avoid code changes (to import_csv.pl on p.61) we suggest you change the .conf file to a .yml file by renaming addressbook.conf to addressbook.yml and then add a ':' into the first uncommented line so that it reads thus: "name: AddressBook" (no ""). It should not be ":name AddressBook" as may be suggested in the comment lines at the start of the file.
* On page 57, not mentioned, but the code to enable use of flash must be put before the line
__PACKAGE__->setup();
Failure to do this will result in the development server showing an error "Setting config after setup has been run is not allowed."
* On page 58, not explicitly mentioned, use similar code for the edit action in the person.pm controller, and then for both delete and edit actions in the address.pm controller, to remove further stray url tails by redirecting instead of forwarding. Good coding practice for newbies.
## Chapter 4
* Page 69 - The last paragraph mentions <code>uri_with</code> as being a method of <code>$c->response</code>. In fact, <code>uri_with</code> belongs to [Catalyst::Request](http://search.cpan.org/perldoc?Catalyst%3A%3ARequest), and the text should read "The key to this is the <code>$c->request->uri_with</code> (<code>[% Catalyst.req.uri_with(...) %]</code> inside the template) method.". Later in the paragraph, <code>[% Catalyst.res,uri_with({ page => 15 }) %]</code> should read <code>[% Catalyst.req.uri_with({ page => 15 }) %]</code>.
* Page 71 - Regarding the [% INCLUDE %] directive of TT2 states:
"it's possible for the included templates to modify variables in the calling
template. If you'd rather not want this to happen, use the [% PROCESS %]
directive instead."
The [TT2 Docs](http://www.template-toolkit.org/docs/manual/Directives.html#section_INCLUDE)
state "The INCLUDE directive localises (i.e. copies) all variables before processing the template. Any changes made within the included template will not affect variables in the including template." Later, "If you're not worried about preserving variable values, or you trust the templates you're including then you might prefer to use the PROCESS directive which is faster by virtue of not performing any localisation."
See the TT2 documentation for localization subtleties.
* Beginning on page 72 - The Authentication methods cover an older version of the Authentication API. While this remains functional, new applications should use the current API. The Database sections are OK - but the configuration / actions need updating to be compliant with the current version of the API. See [the current API documentation](http://search.cpan.org/~jayk/Catalyst-Plugin-Authentication/) for more details.
* Page 79, first paragraph - "If it matches a user database, [NS0-501](http://www.a1certifications.com/NS0-501.html) the login succeeds." should of course read "If it matches a user in the database, the login succeeds."
* Page 79, first paragraph - "If it matches a user database, the login succeeds." should of course read "If it matches a user in the database, the login succeeds."
## Chapter 5
* On page 84 <br />
<tt>pid INTEGER</tt> <br />
instead of <br />
<strike><tt>pid INTEGER NOT NULL</tt> <br /></strike>
worked for me in addition to page 86, Nicknames.pm:<br />
<tt> "pid", { data_type => "INTEGER", is_nullable=><b>1</b>, size => undef}</tt>
.
* On page 85 relationsips may be generated by <br />
<tt>
$ perl script/chatstat_create.pl model [...] dbi:SQLite:root/database
</tt> <br />
instead of <br />
<strike>
$ perl script/app_ircxory_create.pl model [...] DBI:SQLite:root/database
</strike><br />
note the lowercase 'dbi', you may be accused thus 'You failed to provide any connection info' with upper case.<br />
* With commands On page 85 Chat<nop>Stat/lib/Chat<nop>Stat/Model/DBIC.pm is generated. <br />
It lacks the following lines to work for me. <br />
To call <i>http://Catalyst-Server/things/re.pl</i> after page 110 I had to insert following code to Chat<nop>Stat/lib/ChatStat/Model/DBIC.pm, which was generated with commands from page 85.<br /> I found them in the downloadable source from the book.:
<tt>
sub ACCEPT_CONTEXT {
my $self = shift;
$self->NEXT::ACCEPT_CONTEXT(@_);
return $self->schema;
}
</tt>
* On page 90/91 lib/ChatStat/Schema.pm lacks, AFAIK, a method <i>parse_nickname</i>: <br />
(20080422 - inserted into Schema.pm from source listing Chat<nop>Stat::Robot::Parser.pm in Source-Package [http://jrock.us/Catalyst-Book-Code-20080131.tar.gz](http://jrock.us/Catalyst-Book-Code-20080131.tar.gz))
<tt>
sub parse_nickname { <br />
my $in = shift; <br />
my ($nick, $hoststuff) = split /!~?/, $in; <br />
my ($user, $host) = split /@/, $hoststuff; <br />
return ($nick, $user, $host); <br />
}
</tt>
* Page 92, line 6: should read my $parse = Chat<nop>Stat::Action->new( $who, $channel, $message );. ($channel and $who are reversed in the book).
* Page 101, bottom - <code>right_title = 'Ten right side'</code> should read <code>right_title = 'The right side'</code>
* Page 103, first text paragraph: "We use <code>PROCESS</code> instead of <code>INCLUDE</code> so that the macros are treated though<strike>t</strike> they were actually typed inside <code><strike>main</strike>index.tt2</code>."
## Chapter 6
## Chapter 7
* On page 135 the configuration part of the REST controller doesn't seem to work with recent versions of Catalyst::Controller::REST. If this breaks for you try __PACKAGE__->config->{'default'} = 'application/json';
* On page 136, "but we're overriding it's" shouldn't have the final apostrophe and should read, "but we're overriding its"
* On Pages 137 through 142 all references to $c->req->data should be $c->req->param.
* On page 138 the JSON fallback response has "fulname". This should, of course, be "fullname".
* On page 148, Jemplate.process(...) in Firefox gets XML from the REST API. IE + Safari return the default JSON. This breaks Jemplate on FF because Jemplate only handles JSON. A quick fix was to patch the Ajax.get function in the static Jemplate.js file to include req.setRequestHeader("Accept", "text/json; text/x-json; application/json"); just after the req.open line. This has been fixed in Jemplate release 0.21 (although that release seems to break backwards compatibility).
* On page 149, in javascript function definition cancel_address_edit():
var data = Jemplate.Ajax.get('[%
* Page 151, RSS: "An RSS feed is an XML format designed to let users subscribe to website and [...]" - "a website", or "websites"
* Page 152: "If your application has multiple sources of data <strike>that</strike>then you want to create a View that converts the stash to an RSS feed, instead."
## Chapter 8
* Page 155, the last complete sentence has an extra comma after "but you"
* Page 156, first paragraph: "Even though it seems like <strike>do</strike> actually you're wasting time"
* Page 156, second paragraph: "before I start writing <strike>a</strike> code for it"
* On page 157, "Test::More.Test::More" should read "Test::More"
* Page 162, "Here's the code for a module that does that": <code>Chatstat</code> should have been camelcased to <code>ChatStat</code>.
* Page 162: the source code should have <code>my $db = $tmp->touch('db');</code> added before <code>my $dsn = "DBI:SQLite:$db";</code>.
* Page 162: <code>$config = "$Bin/../chatstat_local.yml";</code> This method of creating the conf file won't work if there are tests in sub directories in the t/ directory.
* Page 163, first paragraph: there is an extra apostrophe in "which list's every"
* On page 178, "'hostname'" should read "\`hostname\`" (backticks instead
of single quotes).
of single quotes).
<pre lang="HTML">
say "Howdy partner.";
</pre>