package Cookbook::Registry; use Apache::Constants qw(OK NOT_FOUND); use Apache::RegistryNG; use strict; @Cookbook::Registry::ISA = qw(Apache::RegistryNG); sub sub_wrap { # Allow Registry scripts to use the handler syntax. my($pr, $code, $package) = @_; $code ||= $pr->{'code'}; $package ||= $pr->{'namespace'}; # Replace the package identifier with the one # generated by Apache::Registry. (my $sub = $$code) =~ s/^(package ).*;/$1$package;/; $pr->{'sub'} = \$sub; } sub can_compile { # Only check for readable files with content. my $pr = shift; my $r = $pr->{r}; if (-r $r->finfo && -s _) { $pr->{'mtime'} = -M _; return OK; } $r->log_error($r->filename, " not found or unable to stat"); return NOT_FOUND; } sub run { my ($pr, @args) = @_; # Capture both the Apache::RegistryNG return code # and the return code of our handler. my ($ng_rc, $rc) = shift->SUPER::run(@args); # If RegistryNG executed OK, return the return code from our handler. return ($ng_rc == OK) ? $rc : $ng_rc; } 1;