Hey All --

> - Added cgiapp_prerun() hook, for adding global behaviors 
>   before the run-mode method is called.  The cgiapp_prerun()
>   gets the name of the run-mode as a parameter.  This would
>   allow the user to perform some action based on the
>   current run-mode.


This feature is going to be of interest to a number of you.  It is similar
to cgiapp_init(), but it is called when run() is called (as opposed to when
new() is called).  This means that we actually know the run-mode name.  The
run-mode is thus passed to the cgiapp_init() method.

A number of you asked about implementing run-mode level authorization.  The
cgiapp_prerun() hook would allow you to do something line this:

  package MyCustom::CGI::Application;
  use base qw/CGI::Application/;

  sub cgiapp_prerun {
    my $self = shift;
    my $run_mode = shift;

    my $is_user_allowed = $self->is_user_allowed($run_mode);

    $self->param('IS_USER_ALLOWED', $is_user_allowed);
  }


In this example, your is_user_allowed() method would return a Boolean which
would be propagated to every run-mode via the 'IS_USER_ALLOWED' parameter.
Every run-mode could check this parameter and respond reasonably.

This hook could also be used for a variety of other purposes.  It could set
up an HTTP redirect, or perform some initialization which would not be
appropriate in cgiapp_init().  The new module, CGI::Application::Mailform,
utilizes this hook to verify run-time parameters.


Warmest regards,

-Jesse-



  Jesse Erlbaum, CTO
  Vanguard Media
  http://www.vm.com
  212.242.5317 x115
  [EMAIL PROTECTED]



---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/cgiapp@lists.vm.com/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to