Author: spadkins
Date: Wed Oct 28 11:09:50 2009
New Revision: 13446
Modified:
p5ee/trunk/App-Context/lib/App/Context.pm
Log:
introduced deprecated flag for services in the service() method
Modified: p5ee/trunk/App-Context/lib/App/Context.pm
==============================================================================
--- p5ee/trunk/App-Context/lib/App/Context.pm (original)
+++ p5ee/trunk/App-Context/lib/App/Context.pm Wed Oct 28 11:09:50 2009
@@ -10,6 +10,7 @@
use App;
+use Carp qw(confess shortmess);
use Date::Format;
use IO::Handle; # for the STDOUT->autoflush() method
use IO::Socket;
@@ -527,6 +528,7 @@
my ($self, $type, $name, %named) = @_;
$self->dbgprint("Context->service(" . join(", ",@_) . ")")
if ($App::DEBUG && $self->dbg(3));
+ my $options = $self->{options};
my ($args, $new_service, $override, $lightweight, $attrib);
my ($service, $conf, $class, $session);
@@ -562,7 +564,6 @@
# Load extra conf on demand
##############################################################
if (!$service_initialized && !$service_conf && $name !~ /-/) { # if it's
not a contained widget, try the file system
- my $options = $self->{options};
my $prefix = $options->{prefix};
my $conf_type = $options->{conf_type} || "pl";
my $conf_file = "$prefix/etc/app/$type.$name.$conf_type";
@@ -575,6 +576,27 @@
}
##############################################################
+ # Detect Deprecated Services
+ ##############################################################
+ if (!$service_initialized && $service_conf) {
+ if ($service_conf->{deprecated}) {
+ my $message_suffix = $service_conf->{deprecated};
+ my $message = "WARNING: $type($name) deprecated";
+ $message .= ": $message_suffix" if ($message_suffix ne "1");
+ my $deprecated_action =
$options->{"app.Context.deprecated_action"};
+ if (!$deprecated_action || $deprecated_action eq "none") {
+ # do nothing
+ }
+ elsif ($deprecated_action eq "die") {
+ confess $message;
+ }
+ else {
+ $self->log(shortmess($message));
+ }
+ }
+ }
+
+ ##############################################################
# aliases
##############################################################
if (!$service_initialized && $service_conf) {
@@ -596,7 +618,6 @@
# conf includes
##############################################################
if (!$service_initialized && $service_conf && $service_conf->{include}) {
- my $options = $self->{options};
my $prefix = $options->{prefix};
my (@include_files);
my $include_files = $service_conf->{include};