added ability to turn on/off added content lookups via memcache key
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 25 Apr 2007 20:57:23 +0000 (20:57 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 25 Apr 2007 20:57:23 +0000 (20:57 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_0@7170 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/WWW/AddedContent.pm
Open-ILS/src/support-scripts/ac_ctl.pl [new file with mode: 0755]

index 49beceb..b7b94f1 100644 (file)
@@ -31,6 +31,7 @@ sub import {
 
 
 my $net_timeout;
+my $cache;
 sub child_init {
 
        OpenSRF::System->bootstrap_client( config_file => $bs_config );
@@ -40,6 +41,8 @@ sub child_init {
 
     return unless $ac_data;
 
+    $cache = OpenSRF::Utils::Cache->new;
+
        my $ac_handler = $ac_data->{module};
     $net_timeout = $ac_data->{timeout} || 3;
     
@@ -68,6 +71,13 @@ sub handler {
        child_init() unless $handler; # why isn't apache doing this for us?
        return Apache2::Const::NOT_FOUND unless $handler;
 
+    # if this memcache key is set, added content lookups are disabled
+       if( $cache->get_cache('ac.no_lookup') ) {
+        $logger->info("added content lookup disabled");
+           return Apache2::Const::NOT_FOUND;
+    }
+
+
        my( undef, $data, $format, $key ) = split(/\//, $r->path_info);
 
        my $err;
diff --git a/Open-ILS/src/support-scripts/ac_ctl.pl b/Open-ILS/src/support-scripts/ac_ctl.pl
new file mode 100755 (executable)
index 0000000..3b260b8
--- /dev/null
@@ -0,0 +1,27 @@
+#!/usr/bin/perl
+use strict; use warnings;
+
+use OpenSRF::AppSession;
+use OpenSRF::System;
+use OpenSRF::Utils::SettingsClient;
+use OpenSRF::Utils::Cache;
+
+my $config = shift;
+my $command = shift;
+die <<USAGE
+
+    Enables/disables added content lookups in apache.  This does not (currently)
+    include jacket image lookups, which are Apache rewrites
+
+    usage: perl $0 <bootstrap_config> [enable|disable]
+
+USAGE
+    unless $command;
+
+OpenSRF::System->bootstrap_client(config_file => $config);
+
+my $cache = OpenSRF::Utils::Cache->new;
+$cache->put_cache('ac.no_lookup', 1) if $command eq 'disable';
+$cache->delete_cache('ac.no_lookup') if $command eq 'enable';
+
+