Marcus Ramberg > Catalyst-Runtime-5.7001 > Catalyst::Manual::Tutorial::Appendices

Download:
Catalyst-Runtime-5.7001.tar.gz

Annotate this POD

CPAN RT

New  5
Open  7
Stalled  4
View Bugs
Report a bug
Source   Latest Release: Catalyst-Runtime-5.7003

NAME ^

Catalyst::Manual::Tutorial::Appendices - Catalyst Tutorial - Part 9: Appendices

OVERVIEW ^

This is Part 9 of 9 of the Catalyst tutorial.

Tutorial Overview

  1. Introduction
  2. Catalyst Basics
  3. Basic CRUD
  4. Authentication
  5. Authorization
  6. Debugging
  7. Testing
  8. AdvancedCRUD
  9. Appendices

DESCRIPTION ^

This part of the tutorial provides supporting information relevant to the Catalyst tutorial.

APPENDIX 1: CUT AND PASTE FOR POD-BASED EXAMPLES ^

You may notice that Pod indents example code with four spaces. This section provides some quick advice to "un-indent" this text in common editors.

"Un-indenting" with Vi/Vim

When cutting and pasting multi-line text from Pod-based documents, the following vi/vim regexs can be helpful to "un-indent" the inserted text (do NOT type the quotes, they are only included to show spaces in the regex patterns). Note that all 3 of the regexs end in 4 spaces:

"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 replace the leading spaces of every line in a file, use:

    M-x replace-regexp<RET>
    Replace regexp: ^    <RET>
    with: <RET>

All of that will occur on the single line at the bottom of your screen. Note that "<RET>" 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-SPC 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.

APPENDIX 2: USING MYSQL AND POSTGRESQL ^

The main database used in this tutorial is the very simple yet powerful SQLite. This section provides information that can be used to "convert" the tutorial to use MySQL and PostgreSQL. However, note that part of the beauty of the MVC architecture is that very little database-specific code is spread throughout the system (at least when MVC is "done right"). Consequently, converting from one database to another is relatively painless with most Catalyst applications. In general, you just need to adapt the schema definition .sql file you use to initialize your database and adjust a few configuration parameters.

Also note that the purpose of the data definition statements for this section are not designed to take maximum advantage of the various features in each database for issues such as referential integrity and field types/constraints.

MySQL

Use the following steps to adapt the tutorial to MySQL. Thanks to Jim Howard for the help.

PostgreSQL

TODO -- Please see the latest version of this document for possible updates: http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Runtime/lib/Catalyst/Manual/Tutorial/Appendices.pod

APPENDIX 3: IMPROVED HASHING SCRIPT ^

Here is an improved SHA-1 hashing script from Gavin Henry that does not expose the passwords to "capture" on the command line.

    #!/usr/bin/perl -w
    #===============================================================================
    #
    #         FILE:  enc_pass.pl
    #
    #        USAGE:  ./enc_pass.pl
    #
    #  DESCRIPTION:  Encrypt a Password using SHA-1
    #
    #      OPTIONS:  ---
    # REQUIREMENTS:  ---
    #         BUGS:  ---
    #        NOTES:  ---
    #       AUTHOR:  Gavin Henry (GH), <ghenry@suretecsystems.com>
    #      COMPANY:  Suretec Systems Ltd.
    #      VERSION:  1.0
    #      CREATED:  26/06/2006
    #     REVISION:  ---
    #    COPYRIGHT:  http://search.cpan.org/dist/perl/pod/perlgpl.pod
    #===============================================================================
    
    use strict;
    use warnings;
    use Digest::SHA1;
    use Term::ReadKey;
    
    sub get_pass {
        ReadMode 'noecho';
        chomp( my $pw = ReadLine 0 );
        ReadMode 'normal';
        return $pw;
    }
    
    print "Enter the password to be encrypted: ";
    my $pass = get_pass();
    
    print "\nConfirm the password: ";
    my $verify = get_pass();
    
    if ( $pass eq $verify ) {
        my $sha1_enc = Digest::SHA1->new;
        $sha1_enc->add($pass);
    
        print "\nYour encrypted password is: "
          . $sha1_enc->hexdigest . "\n"
          . "Paste this into your SQL INSERT/COPY Data.\n";
    }
    else {
        print "\nPasswords do not match!\n";
    }

AUTHOR ^

Kennedy Clark, hkclark@gmail.com

Please report any errors, issues or suggestions to the author. The most recent version of the Catalyst Tutorial can be found at http://dev.catalyst.perl.org/repos/Catalyst/trunk/Catalyst-Runtime/lib/Catalyst/Manual/Tutorial/.

Copyright 2006, Kennedy Clark, under Creative Commons License (http://creativecommons.org/licenses/by-nc-sa/2.5/).