X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Manual.git;a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FTutorial%2FAppendices.pod;h=fe5606e166422c93f99b50af5cfecf749cf2bf0f;hp=cad622e6bfb29832e79c3892b908ce82982f5c05;hb=a46b474eb241c3eac09ac0cd8af400a864de3ee5;hpb=3533daff0314522f79dff9c618da087568f1378c diff --git a/lib/Catalyst/Manual/Tutorial/Appendices.pod b/lib/Catalyst/Manual/Tutorial/Appendices.pod index cad622e..fe5606e 100644 --- a/lib/Catalyst/Manual/Tutorial/Appendices.pod +++ b/lib/Catalyst/Manual/Tutorial/Appendices.pod @@ -1,11 +1,11 @@ =head1 NAME -Catalyst::Manual::Tutorial::Appendices - Catalyst Tutorial - Part 10: Appendices +Catalyst::Manual::Tutorial::Appendices - Catalyst Tutorial - Chapter 10: Appendices =head1 OVERVIEW -This is B for the Catalyst tutorial. +This is B for the Catalyst tutorial. L @@ -56,7 +56,7 @@ B =head1 DESCRIPTION -This part of the tutorial provides supporting information relevant to +This chapter of the tutorial provides supporting information relevant to the Catalyst tutorial. @@ -75,28 +75,28 @@ regex patterns). I: =over 4 -=item * +=item * ":0,$s/^ " Removes four leading spaces from the entire file (from the first line, C<0>, to the last line, C<$>). -=item * +=item * "%s/^ " A shortcut for the previous item (C<%> specifies the entire file; so this removes four leading spaces from every line). -=item * +=item * ":.,$s/^ " Removes the first four spaces from the line the cursor is on at the time the regex command is executed (".") to the last line of the file. -=item * +=item * ":.,44s/^ " @@ -107,8 +107,8 @@ Removes four leading space from the current line through line 44 =head2 "Un-indenting" with Emacs -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 +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: M-x replace-regexp @@ -116,13 +116,13 @@ replace the leading spaces of every line in a file, use: with: All of that will occur on the single line at the bottom of your screen. -Note that "" represents the return key/enter. Also, there are +Note that "" represents the return key/enter. Also, there are four spaces after the "^" on the "Replace regexp:" line and no spaces entered on the last line. You can limit the replacement operation by selecting text first (depending -on your version of emacs, you can either use the mouse or experiment with -commands such as C to set the mark at the cursor location and +on your version of Emacs, you can either use the mouse or experiment with +commands such as C to set the mark at the cursor location and C> and C> to set the mark at the beginning and end of the file respectively. @@ -146,14 +146,14 @@ field types/constraints. =head2 MySQL -Use the following steps to adapt the tutorial to MySQL. Thanks to Jim +Use the following steps to adapt the tutorial to MySQL. Thanks to Jim Howard for the help. =over 4 =item * -Part 2: Catalyst Basics +Chapter 2: Catalyst Basics =over 4 @@ -173,7 +173,7 @@ The Perl C module =back -For CentOS users (see +For CentOS users (see L), you can use the following commands to install the software and start the MySQL daemon: @@ -321,7 +321,8 @@ Delete the existing model: Regenerate the model using the Catalyst "_create.pl" script: - script/myapp_create.pl model MyAppDB DBIC::Schema MyAppDB dbi:mysql:myapp 'tutorial' '' '{ AutoCommit => 1 }' + script/myapp_create.pl model MyAppDB DBIC::Schema MyApp::Schema \ + dbi:mysql:myapp '_username_here_' '_password_here_' '{ AutoCommit => 1 }' =back @@ -329,7 +330,7 @@ Regenerate the model using the Catalyst "_create.pl" script: =item * -Part 4: Authentication +Chapter 4: Authentication =over 4 @@ -405,14 +406,14 @@ Load the user/roles data: =head2 PostgreSQL Use the following steps to adapt the tutorial to PostgreSQL. Thanks to -Louis Moore for the help who was in turn helped by Marcello Romani and +Louis Moore for the help who was in turn helped by Marcello Romani and Tom Lanyon. =over 4 =item * -Part 2: Catalyst Basics +Chapter 2: Catalyst Basics =over 4 @@ -436,14 +437,14 @@ The Perl C module Create the database and a user for the database - $ createuser -P catmyapp - Enter password for new role: + $ createuser -P catappuser + Enter password for new role: Enter it again: Shall the new role be a superuser? (y/n) n Shall the new role be allowed to create databases? (y/n) n Shall the new role be allowed to create more new roles? (y/n) n CREATE ROLE - $ createdb -O catmyapp mycatapp + $ createdb -O catappuser catappdb CREATE DATABASE =item * @@ -457,94 +458,93 @@ Create the C<.sql> file and load the data: Open the C in your editor and enter: - -- - -- Create a very simple database to hold book and author information - -- - -- The sequence is how we get a unique id in PostgreSQL - -- - CREATE SEQUENCE books_seq START 5 ; - SELECT nextval ('books_seq'); - - CREATE TABLE books ( - id INTEGER PRIMARY KEY DEFAULT nextval('books_seq'), - title TEXT , - rating INTEGER - ); - - -- 'book_authors' is a many-to-many join table between books & authors - CREATE TABLE book_authors ( - book_id INTEGER, - author_id INTEGER, - PRIMARY KEY (book_id, author_id) - - ); - - CREATE SEQUENCE authors_seq START 8 ; - SELECT nextval ('authors_seq'); - - CREATE TABLE authors ( - id INTEGER PRIMARY KEY DEFAULT nextval('authors_seq'), - first_name TEXT, - last_name TEXT - ); - --- - --- Load some sample data - --- - INSERT INTO books VALUES (1, 'CCSP SNRS Exam Certification Guide', 5); - INSERT INTO books VALUES (2, 'TCP/IP Illustrated, Volume 1', 5); - INSERT INTO books VALUES (3, 'Internetworking with TCP/IP Vol.1', 4); - INSERT INTO books VALUES (4, 'Perl Cookbook', 5); - INSERT INTO books VALUES (5, 'Designing with Web Standards', 5); - INSERT INTO authors VALUES (1, 'Greg', 'Bastien'); - INSERT INTO authors VALUES (2, 'Sara', 'Nasseh'); - INSERT INTO authors VALUES (3, 'Christian', 'Degu'); - 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 (8, 'Jeffrey', 'Zeldman'); - INSERT INTO book_authors VALUES (1, 1); - INSERT INTO book_authors VALUES (1, 2); - INSERT INTO book_authors VALUES (1, 3); - INSERT INTO book_authors VALUES (2, 4); - INSERT INTO book_authors VALUES (3, 5); - INSERT INTO book_authors VALUES (4, 6); - INSERT INTO book_authors VALUES (4, 7); - INSERT INTO book_authors VALUES (5, 8); + -- + -- Create a very simple database to hold book and author information + -- + -- The sequence is how we get a unique id in PostgreSQL + -- + CREATE SEQUENCE books_seq START 5 ; + SELECT nextval ('books_seq'); + + CREATE TABLE books ( + id INTEGER PRIMARY KEY DEFAULT nextval('books_seq'), + title TEXT , + rating INTEGER + ); + + -- 'book_authors' is a many-to-many join table between books & authors + CREATE TABLE book_authors ( + book_id INTEGER, + author_id INTEGER, + PRIMARY KEY (book_id, author_id) + ); + + CREATE SEQUENCE authors_seq START 8 ; + SELECT nextval ('authors_seq'); + + CREATE TABLE authors ( + id INTEGER PRIMARY KEY DEFAULT nextval('authors_seq'), + first_name TEXT, + last_name TEXT + ); + --- + --- Load some sample data + --- + INSERT INTO books VALUES (1, 'CCSP SNRS Exam Certification Guide', 5); + INSERT INTO books VALUES (2, 'TCP/IP Illustrated, Volume 1', 5); + INSERT INTO books VALUES (3, 'Internetworking with TCP/IP Vol.1', 4); + INSERT INTO books VALUES (4, 'Perl Cookbook', 5); + INSERT INTO books VALUES (5, 'Designing with Web Standards', 5); + INSERT INTO authors VALUES (1, 'Greg', 'Bastien'); + INSERT INTO authors VALUES (2, 'Sara', 'Nasseh'); + INSERT INTO authors VALUES (3, 'Christian', 'Degu'); + 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 (8, 'Jeffrey', 'Zeldman'); + INSERT INTO book_authors VALUES (1, 1); + INSERT INTO book_authors VALUES (1, 2); + INSERT INTO book_authors VALUES (1, 3); + INSERT INTO book_authors VALUES (2, 4); + INSERT INTO book_authors VALUES (3, 5); + INSERT INTO book_authors VALUES (4, 6); + INSERT INTO book_authors VALUES (4, 7); + INSERT INTO book_authors VALUES (5, 8); =item * Load the data: - $ psql -U catmyapp -W mycatapp - Password for user catmyapp: catalyst + $ psql -U catappuser -W catappdb + Password for user catappuser: Welcome to psql 8.1.8, the PostgreSQL interactive terminal. - + Type: \copyright for distribution terms \h for help with SQL commands \? for help with psql commands \g or terminate with semicolon to execute query \q to quit - - mycatapp=> \i myapp01_psql.sql - + + catappdb=> \i myapp01_psql.sql + CREATE SEQUENCE - nextval + nextval --------- 5 (1 row) - + psql:myapp01_psql.sql:11: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "books_pkey" for table "books" CREATE TABLE - psql:myapp01_psql.sql:19: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "book_authors_pkey" for table + psql:myapp01_psql.sql:19: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "book_authors_pkey" for table "book_authors" CREATE TABLE CREATE SEQUENCE - nextval + nextval --------- 8 (1 row) - + psql:myapp01_psql.sql:30: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "authors_pkey" for table "authors" CREATE TABLE INSERT 0 1 @@ -557,17 +557,17 @@ Load the data: Make sure the data loaded correctly: - mycatapp=> \dt + catappdb=> \dt List of relations - Schema | Name | Type | Owner + Schema | Name | Type | Owner --------+--------------+-------+---------- - public | authors | table | catmyapp - public | book_authors | table | catmyapp - public | books | table | catmyapp + public | authors | table | catappuser + public | book_authors | table | catappuser + public | books | table | catappuser (3 rows) - - mycatapp=> select * from books; - id | title | rating + + catappdb=> select * from books; + id | title | rating ----+------------------------------------+-------- 1 | CCSP SNRS Exam Certification Guide | 5 2 | TCP/IP Illustrated, Volume 1 | 5 @@ -575,8 +575,8 @@ Make sure the data loaded correctly: 4 | Perl Cookbook | 5 5 | Designing with Web Standards | 5 (5 rows) - - mycatapp=> \q + + catappdb=> \q =back @@ -584,29 +584,29 @@ Make sure the data loaded correctly: After the steps where you: - edit lib/MyApp.pm - - create lib/MyAppDB.pm - + edit lib/MyApp.pm + + create lib/MyAppDB.pm + create lib/MyAppDB/Book.pm - + create lib/MyAppDB/Author.pm - - create lib/MyAppDB/BookAuthor.pm + + create lib/MyAppDB/BookAuthor.pm =item * Generate the model using the Catalyst "_create.pl" script: - script/myapp_create.pl model MyAppDB DBIC::Schema MyAppDB 'dbi:Pg:dbname=mycatapp' 'catmyapp' 'catalyst' '{ AutoCommit => 1 }' + script/myapp_create.pl model MyAppDB DBIC::Schema MyAppDB 'dbi:Pg:dbname=catappdb' 'catappuser' 'catalyst' '{ AutoCommit => 1 }' =back =item * -Part 4: Authentication +Chapter 4: Authentication =over 4 @@ -619,10 +619,10 @@ Open C in your editor and enter: -- -- Add users and roles tables, along with a many-to-many join table -- - + CREATE SEQUENCE users_seq START 3 ; SELECT nextval ('users_seq'); - + CREATE TABLE users ( id INTEGER PRIMARY KEY DEFAULT nextval('users_seq'), username TEXT, @@ -632,21 +632,21 @@ Open C in your editor and enter: last_name TEXT, active INTEGER ); - + CREATE SEQUENCE roles_seq START 2 ; SELECT nextval ('roles_seq'); - + CREATE TABLE roles ( id INTEGER PRIMARY KEY DEFAULT nextval('roles_seq'), role TEXT ); - + CREATE TABLE user_roles ( user_id INTEGER, role_id INTEGER, PRIMARY KEY (user_id, role_id) ); - + -- -- Load up some initial test data -- @@ -664,32 +664,32 @@ Open C in your editor and enter: Load the data: - $ psql -U catmyapp -W mycatapp - Password for user catmyapp: catalyst + $ psql -U catappuser -W catappdb + Password for user catappuser: catalyst Welcome to psql 8.1.8, the PostgreSQL interactive terminal. - + Type: \copyright for distribution terms \h for help with SQL commands \? for help with psql commands \g or terminate with semicolon to execute query \q to quit - - mycatapp=> \i myapp02_psql.sql - + + catappdb=> \i myapp02_psql.sql + CREATE SEQUENCE - nextval + nextval --------- 3 (1 row) - + psql:myapp02_psql.sql:16: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "users_pkey" for table "users" CREATE TABLE CREATE SEQUENCE - nextval + nextval --------- 2 (1 row) - + psql:myapp02_psql.sql:24: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "roles_pkey" for table "roles" CREATE TABLE psql:myapp02_psql.sql:30: NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "user_roles_pkey" for table "user_roles" @@ -703,10 +703,10 @@ Load the data: INSERT 0 1 INSERT 0 1 INSERT 0 1 - mycatapp=> - - mycatapp=> select * from users; - id | username | password | email_address | first_name | last_name | active + catappdb=> + + catappdb=> select * from users; + id | username | password | email_address | first_name | last_name | active ----+----------+----------+---------------+------------+-----------+-------- 1 | test01 | mypass | t01@na.com | Joe | Blow | 1 2 | test02 | mypass | t02@na.com | Jane | Doe | 1 @@ -731,17 +731,17 @@ Open C in your editor and enter: Load in the data - $ psql -U catmyapp -W mycatapp - Password for user catmyapp: + $ psql -U catappuser -W catappdb + Password for user catappuser: Welcome to psql 8.1.8, the PostgreSQL interactive terminal. - + Type: \copyright for distribution terms \h for help with SQL commands \? for help with psql commands \g or terminate with semicolon to execute query \q to quit - - mycatapp=> \i myapp03_psql.sql + + catappdb=> \i myapp03_psql.sql UPDATE 1 UPDATE 1 UPDATE 1 @@ -816,7 +816,7 @@ Kennedy Clark, C Please report any errors, issues or suggestions to the author. The most recent version of the Catalyst Tutorial can be found at -L. +L. -Copyright 2006, Kennedy Clark, under Creative Commons License -(L). +Copyright 2006-2008, Kennedy Clark, under Creative Commons License +(L).