X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fp5-CGI-Ex;a=blobdiff_plain;f=lib%2FCGI%2FEx%2FApp.pm;h=d03f90a79c62cdb7d7a14589fad93668bb7e488d;hp=f85becdb794905d57052490448f6e892136ab0fd;hb=490b94ab4051adf93abf16a4ed34efb923d6e8fc;hpb=18123183bfb2737ea337306c9d705fca5b5e50d6 diff --git a/lib/CGI/Ex/App.pm b/lib/CGI/Ex/App.pm index f85becd..d03f90a 100644 --- a/lib/CGI/Ex/App.pm +++ b/lib/CGI/Ex/App.pm @@ -13,7 +13,7 @@ BEGIN { eval { use Scalar::Util }; } -our $VERSION = '2.18'; +our $VERSION = '2.22'; sub new { my $class = shift || croak "Usage: ".__PACKAGE__."->new"; @@ -247,9 +247,9 @@ sub prepared_print { my $self = shift; my $step = shift; + my $hash_form = $self->run_hook('hash_form', $step) || {}; my $hash_base = $self->run_hook('hash_base', $step) || {}; my $hash_comm = $self->run_hook('hash_common', $step) || {}; - my $hash_form = $self->run_hook('hash_form', $step) || {}; my $hash_fill = $self->run_hook('hash_fill', $step) || {}; my $hash_swap = $self->run_hook('hash_swap', $step) || {}; my $hash_errs = $self->run_hook('hash_errors', $step) || {}; @@ -332,7 +332,15 @@ sub template_obj { my ($self, $args) = @_; return $self->{'template_obj'} || do { require Template::Alloy; - my $t = Template::Alloy->new($args); + Template::Alloy->new($args); + }; +} + +sub auth_obj { + my ($self, $args) = @_; + return $self->{'auth_obj'} || do { + require CGI::Ex::Auth; + CGI::Ex::Auth->new($args); }; } @@ -365,7 +373,9 @@ sub conf { $self->{'conf'} = pop if @_ == 1; return $self->{'conf'} ||= do { my $conf = $self->conf_file; - $conf = ($self->conf_obj->read($conf, {no_warn_on_fail => 1}) || $self->conf_die_on_fail ? croak $@ : {}) if ! $conf; + if (! ref $conf) { + $conf = $self->conf_obj->read($conf, {no_warn_on_fail => 1}) || ($self->conf_die_on_fail ? croak $@ : {}); + } my $hash = $self->conf_validation; if ($hash && scalar keys %$hash) { my $err_obj = $self->val_obj->validate($conf, $hash); @@ -640,7 +650,6 @@ sub step_by_path_index { my $i = shift || 0; my $ref = $self->path; return '' if $i < 0; -# return $self->default_step if $i > $#$ref; return $ref->[$i]; } @@ -935,8 +944,7 @@ sub _do_auth { $args->{'verify_user'} ||= sub { my ($auth, $user) = @_; $self->verify_user( $user, $auth) }; $args->{'cleanup_user'} ||= sub { my ($auth, $user) = @_; $self->cleanup_user( $user, $auth) }; - require CGI::Ex::Auth; - my $obj = CGI::Ex::Auth->new($args); + my $obj = $self->auth_obj($args); my $resp = $obj->get_valid_auth; my $data = $obj->last_auth_data;