[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mason-cvs
Subject:    [Mason-checkins] CVS: mason/dist/lib/HTML/Mason Devel.pod,1.153,1.154 Plugin.pm,1.6,1.7 Request.pm,1
From:       Jonathan Swartz <jswartz () users ! sourceforge ! net>
Date:       2004-12-13 20:22:32
Message-ID: E1CdwiG-00048w-BJ () sc8-pr-cvs1 ! sourceforge ! net
[Download RAW message or body]

Update of /cvsroot/mason/mason/dist/lib/HTML/Mason
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15898/dist/lib/HTML/Mason

Modified Files:
	Devel.pod Plugin.pm Request.pm 
Log Message:
add a _hook prefix to the name of each plugin hook method, to distinguish them from \
future user-accessible methods on plugin objects

Index: Devel.pod
===================================================================
RCS file: /cvsroot/mason/mason/dist/lib/HTML/Mason/Devel.pod,v
retrieving revision 1.153
retrieving revision 1.154
diff -u -r1.153 -r1.154
--- Devel.pod	17 Nov 2004 02:11:34 -0000	1.153
+++ Devel.pod	13 Dec 2004 20:22:28 -0000	1.154
@@ -1006,15 +1006,17 @@
 component exits. For example: closing a database connection or closing
 a file handle.
 
-Technically a << <%cleanup> >> block is equivalent to a C<< <%perl> >>
-block at the end of the component. Since a component corresponds a
-subroutine block, and since Perl is so darned good at cleaning up
-stuff at the end of blocks, C<< <%cleanup> >> sections are rarely
+A << <%cleanup> >> block is equivalent to a C<< <%perl> >> block at
+the end of the component. This means it will NOT execute if the
+component explicitly returns, or if an abort or error occurs in that
+component or one of its children. Because of this limitation, and
+because Perl is usually so good about cleaning up at the end of a
+lexical scope (e.g. component), C<< <%cleanup> >> sections are rarely
 needed.
 
-Because of the way Mason compiles components, if your C<< <%init> >>
-section or component body contain a C<return> statement, then your C<<
-<%cleanup> >> block will not be executed.
+If you need code that is guaranteed to run when the component or
+request exits, consider using a mod_perl cleanup handler, or creating
+a custom class with a DESTROY method.
 
 =head2 <%once>
 

Index: Plugin.pm
===================================================================
RCS file: /cvsroot/mason/mason/dist/lib/HTML/Mason/Plugin.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Plugin.pm	9 Dec 2004 20:16:56 -0000	1.6
+++ Plugin.pm	13 Dec 2004 20:22:28 -0000	1.7
@@ -7,22 +7,22 @@
     bless { @_ }, $class;
 }
 
-sub start_request {
+sub start_request_hook {
     # my ($self, $context) = @_;
     # $context has: request, args
 }
 
-sub end_request {
+sub end_request_hook {
     # my ($self, $context) = @_;
     # $context has: request, args, output, wantarray, result, error
 }
 
-sub start_component {
+sub start_component_hook {
     # my ($self, $context) = @_;
     # $context has: request, comp, args
 }
 
-sub end_component {
+sub end_component_hook {
     # my ($self, $context) = @_;
     # $context has: request, comp, args, wantarray, result, error
 }
@@ -41,12 +41,12 @@
    use base qw(HTML::Mason::Plugin);
    use Time::HiRes;
 
-   sub start_component {
+   sub start_component_hook {
        my ($self, $context) = @_;
        push @{$self->{ timers }}, Time::HiRes::time;
    }
 
-   sub end_component {
+   sub end_component_hook {
        my ($self, $context) = @_;
        my $elapsed = Time::HiRes::time - pop @{$self->{ timers }};
        printf STDERR "Component '%s' took %.1f seconds\n",
@@ -74,17 +74,17 @@
 =head1 PLUGIN HOOKS
 
 A plugin class defines one or more of the following hooks (methods):
-I<start_request>, I<end_request>, I<start_component>, and
-I<end_component>.
+I<start_request_hook>, I<end_request_hook>, I<start_component_hook>,
+and I<end_component_hook>.
 
 Every hook receives two arguments: the plugin object itself,
 and a context object with various methods.
 
 =over
 
-=item start_request
+=item start_request_hook
 
-The C<start_request> hook is called before the Mason request begins
+C<start_request_hook> is called before the Mason request begins
 execution.  Its context has the following read-only methods:
 
     request # the current request
@@ -100,16 +100,16 @@
 object and execute this code again; you can skip your code for
 subrequests by checking C<is_subrequest> on I<request>. e.g.
 
-   sub start_request {
+   sub start_request_hook {
        my ($self, $context) = @_;
        unless ($context->request->is_subrequest()) {
            # perform hook action
        }
    }
 
-=item end_request
+=item end_request_hook
 
-The C<end_request> hook is called before the Mason request
+C<end_request_hook> is called before the Mason request
 exits. Its context has the following read-only methods:
 
     request     # the current request
@@ -128,9 +128,9 @@
 modify I<output> to affect what the request outputs, and 
 I<result> and I<error> to affect what the request returns.
 
-=item start_component
+=item start_component_hook
 
-The C<start_component()> hook is called before a component begins
+C<start_component_hook> is called before a component begins
 executing. Its context has the following read-only methods:
 
     request     # the current request
@@ -139,9 +139,9 @@
 
 The plugin may NOT modify I<args> currently.
 
-=item end_component
+=item end_component_hook
 
-The C<end_component()> hook is called after a component has
+C<end_component_hook()> is called after a component has
 completed. Its context has the following read-only methods:
 
     request     # the current request

Index: Request.pm
===================================================================
RCS file: /cvsroot/mason/mason/dist/lib/HTML/Mason/Request.pm,v
retrieving revision 1.338
retrieving revision 1.339
diff -u -r1.338 -r1.339
--- Request.pm	11 Dec 2004 00:53:16 -0000	1.338
+++ Request.pm	13 Dec 2004 20:22:28 -0000	1.339
@@ -434,7 +434,7 @@
 		    'HTML::Mason::Plugin::Context::StartRequest';
 		eval {
 		    foreach my $plugin_instance (@{$self->plugin_instances}) {
-			$plugin_instance->start_request( $context );
+			$plugin_instance->start_request_hook( $context );
 		    }
 		};
 		if ($@) {
@@ -460,7 +460,7 @@
 		    'HTML::Mason::Plugin::Context::EndRequest';
 		eval {
 		    foreach my $plugin_instance (@{$self->{plugin_instances_reverse}}) {
-			$plugin_instance->end_request( $context );
+			$plugin_instance->end_request_hook( $context );
 		    }
 		};
 		if ($@) {
@@ -1204,7 +1204,7 @@
 	    'HTML::Mason::Plugin::Context::StartComponent';
 	
 	foreach my $plugin_instance (@{$self->{plugin_instances}}) {
-	    $plugin_instance->start_component( $context );
+	    $plugin_instance->start_component_hook( $context );
 	}
     }
 
@@ -1246,7 +1246,7 @@
 	    'HTML::Mason::Plugin::Context::EndComponent';
 	
 	foreach my $plugin_instance (@{$self->{plugin_instances_reverse}}) {
-	    $plugin_instance->end_component( $context );
+	    $plugin_instance->end_component_hook( $context );
 	}
     }
 



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
Mason-checkins mailing list
Mason-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-checkins


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic