[Catalyst-commits] r10110 -
Catalyst-Manual/5.70/branches/depluralise/lib/Catalyst/Manual/Tutorial
kiffin at dev.catalyst.perl.org
kiffin at dev.catalyst.perl.org
Wed May 13 13:35:40 GMT 2009
Author: kiffin
Date: 2009-05-13 13:35:40 +0000 (Wed, 13 May 2009)
New Revision: 10110
Modified:
Catalyst-Manual/5.70/branches/depluralise/lib/Catalyst/Manual/Tutorial/Debugging.pod
Log:
Slowly but surely have completed the depluralization modifications required for the debugging chapter.
Modified: Catalyst-Manual/5.70/branches/depluralise/lib/Catalyst/Manual/Tutorial/Debugging.pod
===================================================================
--- Catalyst-Manual/5.70/branches/depluralise/lib/Catalyst/Manual/Tutorial/Debugging.pod 2009-05-13 12:37:12 UTC (rev 10109)
+++ Catalyst-Manual/5.70/branches/depluralise/lib/Catalyst/Manual/Tutorial/Debugging.pod 2009-05-13 13:35:40 UTC (rev 10110)
@@ -128,7 +128,7 @@
# Retrieve all of the book records as book model objects and store in the
# stash where they can be accessed by the TT template
- $c->stash->{books} = [$c->model('DB::Books')->all];
+ $c->stash->{books} = [$c->model('DB::Book')->all];
# Set the TT template to use. You will almost always want to do this
# in your action methods.
@@ -140,6 +140,10 @@
B<NOTE:> The C<DB> here is the Perl Debugger, not the DB model.
+If you haven't done it already, enable SQL logging as before:
+
+ $ export DBIC_TRACE=1
+
To now run the Catalyst development server under the Perl debugger, simply
prepend C<perl -d> to the front of C<script/myapp_server.pl>:
@@ -169,7 +173,7 @@
development server will drop to the Perl debugger prompt:
MyApp::Controller::Books::list(/home/me/MyApp/script/../lib/MyApp/Controller/Books.pm:48):
- 48: $c->stash->{books} = [$c->model('DB::Books')->all];
+ 48: $c->stash->{books} = [$c->model('DB::Book')->all];
DB<1>
@@ -179,7 +183,7 @@
C<single-step> into methods/subroutines):
DB<1> n
- SELECT me.id, me.authors, me.title, me.rating FROM books me:
+ SELECT me.id, me.title, me.rating, me.created, me.updated FROM book me:
MyApp::Controller::Books::list(/home/me/MyApp/script/../lib/MyApp/Controller/Books.pm:53):
53: $c->stash->{template} = 'books/list.tt2';
@@ -191,12 +195,14 @@
Next, list the methods available on our C<Book> model:
- DB<1> m $c->model('DB::Books')
+ DB<1> m $c->model('DB::Book')
()
(0+
(bool
+ __result_class_accessor
__source_handle_accessor
_add_alias
+ __bool
_build_unique_query
_calculate_score
_collapse_cond
@@ -206,8 +212,8 @@
We can also play with the model directly:
- DB<2> x ($c->model('DB::Books')->all)[1]->title
- SELECT me.id, me.title, me.rating FROM books me:
+ DB<2> x ($c->model('DB::Book')->all)[1]->title
+ SELECT me.id, me.title, me.rating, me.created, me.updated FROM book me:
0 'TCP/IP Illustrated, Volume 1'
This uses the Perl debugger C<x> command to display the title of a book.
@@ -219,9 +225,11 @@
0 ARRAY(0xa8f3b7c)
0 MyApp::Model::DB::Book=HASH(0xb8e702c)
'_column_data' => HASH(0xb8e5e2c)
+ 'created' => '2009-05-08 10:19:46'
'id' => 1
'rating' => 5
'title' => 'CCSP SNRS Exam Certification Guide'
+ 'updated' => '2009-05-08 10:19:46'
'_in_storage' => 1
<lines removed for brevity>
@@ -233,17 +241,33 @@
Finally, press C<Ctrl+C> to break out of the development server.
Because we are running inside the Perl debugger, you will drop to the
-debugger prompt. Press C<q> to exit the debugger and return to your OS
+debugger prompt.
+
+ ^CCatalyst::Engine::HTTP::run(/usr/local/share/perl/5.10.0/Catalyst/Engine/HTTP.pm:260):
+ 260: while ( accept( Remote, $daemon ) ) {
+
+ DB<4>
+
+Finally, press C<q> to exit the debugger and return to your OS
shell prompt:
DB<4> q
$
For more information on using the Perl debugger, please see C<perldebug>
-and C<perldebtut>. You can also type C<h> or C<h h> at the debugger
-prompt to view the built-in help screens.
+and C<perldebtut>. For those daring souls out there, you can dive down
+even deeper into the magical depths of this fine debugger by checking
+out C<perldebguts>.
+You can also type C<h> or C<h h> at the debugger prompt to view the
+built-in help screens.
+For an excellent book covering all aspects of the Perl debugger, we highly
+recommend reading 'Pro Perl Debugging' by Richard Foley.
+
+Oh yeah, before you forget, be sure to remove the C<DB::single=1> line you
+added above in C<lib/MyApp/Controller/Books.pm>.
+
=head1 DEBUGGING MODULES FROM CPAN
Although the techniques discussed above work well for code you are
@@ -264,9 +288,9 @@
mkdir -p lib/Module; cp `perldoc -l Module::Name` lib/Module/
-Note: If you are following along in Debian 5, you will need to install
-the C<perl-doc> package to use the C<perldoc> command. Use
-C<sudo aptitude install perl-doc> to do that.
+Note: If you are following along in Debian 5 or Ubuntu, you will
+need to install the C<perl-doc> package to use the C<perldoc> command.
+Use C<sudo aptitude install perl-doc> to do that.
For example, you could make a copy of
L<Catalyst::Plugin::Authentication|Catalyst::Plugin::Authentication>
@@ -295,6 +319,12 @@
'print $Catalyst::Plugin::Authentication::VERSION;'
0.07
+and if you are using bash aliases:
+
+ alias pmver="perl -le '\$m = shift; eval qq(require \$m) \
+ or die qq(module \"\$m\" is not installed\\n); \
+ print \$m->VERSION'"
+
=item *
Check if a modules contains a given method:
@@ -336,6 +366,7 @@
enabled will conflict with several of the conventions used by this
tutorial to leave some variables undefined on purpose).
+Happy debugging.
=head1 AUTHOR
More information about the Catalyst-commits
mailing list