ad_register_filter

one of the documented procedures in this installation of the ACS
Usage:
ad_register_filter { -debug f -priority 10000 -critical f -description "" } kind method path proc args
What it does:
Registers a filter (see ns_register_filter for syntax). Priority is an integer; lower numbers indicate higher priority. Use a method of "*" to register GET, POST, and HEAD filters. If a filter is not critical, page viewing will not abort if a filter fails. If debug is set to "t", all invocations of the filter will be ns_logged.
Defined in: /web/philip/packages/acs-core/request-processor-procs.tcl

Source code:

arg_parser_for_ad_register_filter $args

    if { [string equal $method "*"] } {
	# Shortcut to allow registering filter for all methods.
	foreach method { GET POST HEAD } {
	    eval [concat [list ad_register_filter -debug $debug -priority $priority -critical $critical $kind $method $path $proc] $args]
	}
	return
    }

    if { [lsearch -exact { GET POST HEAD } $method] == -1 } {
	error "Method passed to ad_register_filter must be one of GET, POST, or HEAD"
    }

    # Obtain a lock on the list of filters.
    set mutex [nsv_get rp_filters mutex]
    ns_mutex lock $mutex

    # Append the filter to our list.
    set filters [nsv_get rp_filters "$method,$kind"]
    set filter_info [list $priority $kind $method $path $proc $args $debug $critical $description [info script]]

    # Refuse to register the same thing twice.
    if { [lsearch -exact $filters $filter_info] != -1 } {
	ns_log "Warning" "$kind filter $proc already registered for $method $path"
	ns_mutex unlock $mutex
	return
    }

    # Append the filter and sort based on priority. The -index flag to lsort
    # sorts based on the nth item of each sublist; priority is the 0'th item.
    lappend filters $filter_info
    set filters [lsort -integer -index 0 $filters]

    # Set the array entry and release the lock.
    ns_log "Notice" "Registering $kind filter $proc for $method $path with priority $priority"
    nsv_set rp_filters "$method,$kind" $filters

    ns_mutex unlock $mutex


philg@mit.edu