From 83d198ae340b563b7573ecf89136b32141a82079 Mon Sep 17 00:00:00 2001 From: Jeff Godin Date: Thu, 19 Sep 2013 14:12:43 -0400 Subject: [PATCH] Add method to permit AC handler to expect keyhash Add an expects_keyhash method to OpenILS::WWW::AddedContent::Syndetic and look for it from OpenILS::WWW::AddedContent. This allows us to pass a keyhash (containing isbn/upc/whatever) to this handler while still passing a simple scalar containing an ISBN to other AddedContent handlers. Signed-off-by: Jeff Godin Signed-off-by: Ben Shum --- Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent.pm | 8 +++++++- .../src/perlmods/lib/OpenILS/WWW/AddedContent/Syndetic.pm | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent.pm index a1e14e6e1b..f3c81ae309 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent.pm @@ -157,7 +157,13 @@ sub handler { return Apache2::Const::NOT_FOUND unless @{$keyhash->{isbn}} || @{$keyhash->{upc}}; try { - $data = $handler->$method($keyhash); + if ($handler->can('expects_keyhash') && $handler->expects_keyhash() eq 1) { + # Handler expects a keyhash + $data = $handler->$method($keyhash); + } else { + # Pass single ISBN as a scalar to the handler + $data = $handler->$method($keyhash->{isbn}[0]); + } } catch Error with { $err = shift; decr_error_countdown(); diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/Syndetic.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/Syndetic.pm index 89fe1b445f..1c39733140 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/Syndetic.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/Syndetic.pm @@ -27,6 +27,10 @@ sub userid { return $self->{userid}; } +sub expects_keyhash { + # we expect a keyhash as opposed to a simple scalar containing an ISBN + return 1; +} # -------------------------------------------------------------------------- sub jacket_small { -- 2.43.2