Errata for The Book

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.

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() in DBIx::Class::Schema to make this easier).

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." Should this be to the terminal? Unless maybe it's referring to the terminal as a browser in this case?

  • 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 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'

  • In the code examples on pages 44, 45 and 49, "$c->form" should read "$self->formbuilder" throughout, and the TT code should say "[% FormBuilder.render %]" instead of "[% form.render %]".

(This problem is fixed in the rest of the FormBuilder code, not sure how it got into Chapter 3.)

Chapter 4

  • Page 69 - The last paragraph mentions uri_with as being a method of $c->response. In fact, uri_with belongs to Catalyst::Request, and the text should read "The key to this is the $c->request->uri_with ([% Catalyst.req.uri_with(...) %] inside the template) method.". Later in the paragraph, [% Catalyst.res,uri_with({ page => 15 }) %] should read [% Catalyst.req.uri_with({ page => 15 }) %].

  • 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 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 for more details.

  • 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
    pid INTEGER
    instead of
    pid INTEGER NOT NULL
    worked for me in addition to page 86, Nicknames.pm:
    "pid", { data_type => "INTEGER", is_nullable=>1, size => undef} .

  • On page 85 relationsips may be generated by
    $ perl script/chatstat_create.pl model [...] DBI:SQLite:root/database
    instead of
    $ perl script/app_ircxory_create.pl model [...] DBI:SQLite:root/database

  • With commands On page 85 ChatStat/lib/ChatStat/Model/DBIC.pm is generated.
    It lacks the following lines to work for me.
    To call http://Catalyst-Server/things/re.pl after page 110 I had to insert following code to ChatStat/lib/ChatStat/Model/DBIC.pm, which was generated with commands from page 85.
    I found them in the downloadable source from the book.:

sub ACCEPT_CONTEXT { my $self = shift; $self->NEXT::ACCEPT_CONTEXT(@_); return $self->schema; }

sub parse_nickname {
my $in = shift;
my ($nick, $hoststuff) = split /!~?/, $in;
my ($user, $host) = split /@/, $hoststuff;
return ($nick, $user, $host);
}

  • Page 92, line 6: should read my $parse = ChatStat::Action->new( $who, $channel, $message );. ($channel and $who are reversed in the book).

  • Page 101, bottom - right_title = 'Ten right side' should read right_title = 'The right side'

  • Page 103, first text paragraph: "We use PROCESS instead of INCLUDE so that the macros are treated thought they were actually typed inside mainindex.tt2."

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 page 138 the JSON fallback response has "fulname". This should, of course, be "fullname".

  • On page 138, accessing the API won't work unless you install a serializer, see Catalyst::Controller::REST. Starters should go with JSON::Syck and maybe XML::Simple.

  • 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 thatthen 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 do actually you're wasting time"

  • Page 156, second paragraph: "before I start writing a 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": Chatstat should have been camelcased to ChatStat.

  • Page 162: the source code should have my $db = $tmp->touch('db'); added before my $dsn = "DBI:SQLite:$db";.

  • Page 162: $config = "$Bin/../chatstat_local.yml"; 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).

My tags:
 
Popular tags:
  book, error
Powered by Catalyst