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", "$") %] is poor practice; the correct approach is to use the action object form - [% c.uri_for(c.controller('Person').action_for('edit'), %]

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).

If you are using 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 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 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://"> only needs to appear once.

  • Page 24, " 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 and 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/$") %] etc. is incorrect, see perldoc Catalyst. [% Catalyst.uri_for("person/edit", "$") %] 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 "[% 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.)

  • On page 55, current versions of Catalyst use a .conf file. In order to avoid code changes (to 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 controller, and then for both delete and edit actions in the 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 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
    worked for me in addition to page 86,
    "pid", { data_type => "INTEGER", is_nullable=>1, size => undef} .

  • On page 85 relationsips may be generated by
    $ perl script/ model [...] dbi:SQLite:root/database
    instead of
    $ perl script/ model [...] DBI:SQLite:root/database
    note the lowercase 'dbi', you may be accused thus 'You failed to provide any connection info' with upper case.

  • With commands On page 85 ChatStat/lib/ChatStat/Model/ is generated.
    It lacks the following lines to work for me.
    To call http://Catalyst-Server/things/ after page 110 I had to insert following code to ChatStat/lib/ChatStat/Model/, 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 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 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). of single quotes).

say "Howdy partner.";
My tags:
Popular tags:
  book error
Powered by Catalyst
Powered by MojoMojo Hosted by Shadowcat - Managed by Nordaaker