Add method to permit AC handler to expect keyhash
authorJeff Godin <jgodin@tadl.org>
Thu, 19 Sep 2013 18:12:43 +0000 (14:12 -0400)
committerBen Shum <bshum@biblio.org>
Thu, 26 Sep 2013 17:56:21 +0000 (13:56 -0400)
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 <jgodin@tadl.org>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/Syndetic.pm

index a1e14e6..f3c81ae 100644 (file)
@@ -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();
index 89fe1b4..1c39733 100644 (file)
@@ -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 {