• Publicity: Public Only All

contract-procs.tcl

Support library for acs service contracts.

Location:
packages/acs-service-contract/tcl/contract-procs.tcl
Created:
2003-01-14
Author:
Lars Pind <lars@collaboraid.biz>
CVS Identification:
$Id: contract-procs.tcl,v 1.13.2.4 2023/02/09 14:34:43 antoniop Exp $

Procedures in this file

Detailed information

acs_sc::contract::delete (public)

 acs_sc::contract::delete [ -contract_id contract_id ] [ -name name ] \
    [ -no_cascade ]

Delete a service contract definition. Supply either contract_id or name.

Switches:
-contract_id (optional)
The ID of the service contract to delete
-name (optional)
Name of the service contract to delete
-no_cascade (optional, boolean)

Testcases:
acs_sc_impl_new_from_spec

acs_sc::contract::get_operations (public)

 acs_sc::contract::get_operations -contract_name contract_name

Get a list of names of operations for the contract.

Switches:
-contract_name (required)

Testcases:
acs_sc_impl_new_from_spec

acs_sc::contract::new (public)

 acs_sc::contract::new -name name -description description

Procedure to call to define a new service contract and the message types, implementations and bindings. Refer to the Service contract Tcl API discussion at http://openacs.org/forums/message-view?message_id=71799

Switches:
-name (required)
Name of the service contract
-description (required)
Comment/description of the service contract
Returns:
id of the contract

Testcases:
acs_sc_impl_new_from_spec

acs_sc::contract::new_from_spec (public)

 acs_sc::contract::new_from_spec -spec spec

Takes a complete service contract specification and creates the new service contract.

The spec looks like this:

    set spec {
        name "Action_SideEffect"
        description "Get the name of the side effect to create action"
        operations {
            GetObjectTypes {
                description "Get the object types for which this implementation is valid."
                output { object_types:string,multiple }
                iscachable_p "t"
            }
            GetPrettyName {
                description "Get the pretty name of this implementation."
                output { pretty_name:string }
                iscachable_p "t"
            }
            DoSideEffect {
                description "Do the side effect"
                input {
                    case_id:integer
                    object_id:integer
                    action_id:integer
                    entry_id:integer
                }
            }
        }
    }

    acs_sc::contract::new_from_spec -spec $spec
    
Here's the detailed explanation:

The spec should be an array-list with 3 entries:

  • name: The name of the service contract.
  • description: A human-readable description.
  • operations: An array-list of operations in this service contract.
The operations array-list has the operation name as key, and another array-list containing the specification for the operation as the value. That array-list has the following entries:
  • description: Human-readable description of the operation.
  • input: Specification of the input to this operation.
  • output: Specification of the output of this operation.
  • iscachable_p: A 't' or 'f' for whether output from this service contract implementation should automatically be cached using util_memoize.

The format of the 'input' and 'output' specs is a Tcl list of parameter specs, each of which consist of name, colon (:), datatype plus an optional comma (,) and the flag 'multiple'.

Switches:
-spec (required)
The service contract specification as described above.
Returns:
The contract_id of the newly created service contract.
See Also:

Testcases:
acs_sc_impl_new_from_spec

acs_sc::contract::operation::delete (public)

 acs_sc::contract::operation::delete [ -operation_id operation_id ] \
    [ -contract_name contract_name ] \
    [ -operation_name operation_name ]

Delete the operation.

Switches:
-operation_id (optional)
ID of the operation.
-contract_name (optional)
Name of the contract.
-operation_name (optional)
Name of the operation.

Testcases:
acs_sc_impl_new_from_spec

acs_sc::contract::operation::new (public)

 acs_sc::contract::operation::new -contract_name contract_name \
    -operation operation -input input -output output \
    -description description [ -is_cachable_p is_cachable_p ]

Call the service contract function to create the operation in the database.

Switches:
-contract_name (required)
-operation (required)
-input (required)
-output (required)
-description (required)
-is_cachable_p (optional)

Testcases:
acs_sc_impl_new_from_spec
[ show source ]