Index: openacs-4/packages/acs-service-contract/tcl/acs-service-contract-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-service-contract/tcl/acs-service-contract-procs.tcl,v diff -u -N -r1.25 -r1.26 --- openacs-4/packages/acs-service-contract/tcl/acs-service-contract-procs.tcl 8 Dec 2012 18:20:36 -0000 1.25 +++ openacs-4/packages/acs-service-contract/tcl/acs-service-contract-procs.tcl 27 Oct 2014 16:39:44 -0000 1.26 @@ -22,18 +22,20 @@ {-call_args {}} {-error:boolean} } { - A wrapper for the acs_sc_call procedure, with explicitly named - parameters so it's easier to figure out how to use it. - You must supply either contract and impl, or just impl_id. + A replacement of the former acs_sc_call procedure. + One must supply either contract and impl, or just impl_id. If you supply impl_id and contract, we throw an error if the impl_id's contract doesn't match the contract you passed in. If you supply both impl_id and impl, we throw an error. + + Additional documentation and commentary at http://openacs.org/forums/message-view?message_id=108614. @param contract_name The name of the contract you wish to use. @param operation_name The name of the operation in the contract you wish to call. @param impl The name of the implementation you wish to use. @param impl_id The ID of the implementation you wish to use. @param args The arguments you want to pass to the proc. @param error If specified, will throw an error if the operation isn't implemented. + @author Lars Pind (lars@collaboraid.biz) @see acs_sc_call @@ -52,7 +54,19 @@ if { $impl eq "" || $contract eq "" } { error "You must supply either impl_id, or contract and impl to acs_sc::invoke" } - return [acs_sc_call -error=$error_p $contract $operation $call_args $impl] + + set proc_name [acs_sc_generate_name $contract $impl $operation] + + if { [info commands $proc_name] ne "" } { + return [ad_apply $proc_name $call_args] + } + + if { $error_p } { + error "Operation $operation is not implemented in '$impl' implementation of contract '$contract'" + } else { + ns_log warning "ACS-SC: Function Not Found: $proc_name [info commands $proc_name]" + } + return } @@ -108,7 +122,7 @@ # LARS set exists_p [acs_sc_binding_exists_p $contract $impl] - #set exists_p [util_memoize "acs_sc_binding_exists_p $contract $impl"] + #set exists_p [util_memoize [list acs_sc_binding_exists_p $contract $impl]] if {![set exists_p]} {return ""} @@ -118,17 +132,14 @@ } - - - ad_proc -private acs_sc_proc { contract operation impl {impl_alias {}} {impl_pl {}} } { - Builds the proc used by acs_sc_call, generally only called + Builds the proc used by acs_sc::invoke, generally only called in acs-service-contract-init.tcl at startup. @return 0 on failure, 1 on success. @@ -142,7 +153,7 @@ acs_sc_log SCDebug "ACS_SC_PROC: proc_name = $proc_name" if { $impl_alias eq "" } { - foreach {impl_alias impl_pl} [acs_sc_get_alias $contract $operation $impl] break + lassign [acs_sc_get_alias $contract $operation $impl] impl_alias impl_pl } if { $impl_alias eq "" } { @@ -154,7 +165,7 @@ return 0 } - append docblock "\nacs-service-contract operation. Call via acs_sc_call.\n\n$operation_desc\n\n" + append docblock "\nacs-service-contract operation. Call via acs_sc::invoke.\n\n$operation_desc\n\n" db_foreach operation_inputtype_element {*SQL*} { lappend arguments "$element_name" @@ -171,7 +182,7 @@ } } - append docblock "\n@see $impl_alias\n@see acs_sc_call" + append docblock "\n@see $impl_alias\n@see acs_sc::invoke" set full_statement [acs_sc_get_statement $impl_alias $impl_pl $arguments] @@ -230,9 +241,6 @@ return $full_statement } - - - ad_proc -private -deprecated acs_sc_call { {-error:boolean} contract @@ -252,19 +260,9 @@ @see acs_sc::invoke } { - set proc_name [acs_sc_generate_name $contract $impl $operation] + acs_sc::invoke -contract $contract -operation $operation -impl $impl -call_args $arguments -error=$error_p +} - if { [info commands $proc_name] ne "" } { - return [ad_apply $proc_name $arguments] - } else { - if { $error_p } { - error "Operation $operation is not implemented in '$impl' implementation of contract '$contract'" - } else { - ns_log warning "ACS-SC: Function Not Found: $proc_name [info commands $proc_name]" - } - return - } -} ##