Home
The Toolkit for Online Communities
15936 Community Members, 1 member online, 2837 visitors today
Log In Register

utilities-procs.tcl

OpenACS Home : ACS API Browser : ACS Tcl 5.5.1 : utilities-procs.tcl
Publicity:
[Public Only | All]

utilities-procs.tcl

Provides a variety of non-ACS-specific utilities, including the procs to support the who's online feature.
Location:
packages/acs-tcl/tcl/utilities-procs.tcl
Created:
13 April 2000
Author:
Various <acs@arsdigita.com>
CVS Identification:
$Id: utilities-procs.tcl,v 1.116 2009/02/13 20:28:08 jeffd Exp $

Procedures in this file

Detailed information

NsSettoTclString (public)

NsSettoTclString set_id
returns a plain text version of the passed ns_set id

Parameters:
set_id
 

ReturnHeaders (public)

ReturnHeaders [ content_type ]
We use this when we want to send out just the headers and then do incremental writes with ns_write. This way the user doesn't have to wait for streamed output (useful when doing bulk uploads, installs, etc.). It returns status 200 and all headers including any added to outputheaders.

Parameters:
content_type (defaults to "text/html")
 

ad_block_sql_urls (public)

ad_block_sql_urls conn args why
Deprecated.

A filter that detect attempts to smuggle in SQL code through form data variables. The use of bind variables and ad_page_contract input validation to prevent SQL smuggling is preferred.

Parameters:
conn
args
why

See Also:
 

ad_cache_returnredirect (public)

ad_cache_returnredirect url [ persistent ] [ excluded_vars ]
An addition to ad_returnredirect. It caches all variables in the redirect except those in excluded_vars and then calls ad_returnredirect with the resultant string.

Parameters:
url
persistent (defaults to "f")
excluded_vars (optional)
Author:
Brad Duell <bduell@ncacasi.org>
 

ad_call_proc_if_exists (public)

ad_call_proc_if_exists proc [ args... ]
Calls a procedure with particular arguments, only if the procedure is defined.

Parameters:
proc
 

ad_dbclick_check_dml (public)

ad_dbclick_check_dml [ -bind bind ] statement_name table_name \
    id_column_name generated_id return_url insert_dml
This proc is used for pages using double click protection. table_name is table_name for which we are checking whether the double click occured. id_column_name is the name of the id table column. generated_id is the generated id, which is supposed to have been generated on the previous page. return_url is url to which this procedure will return redirect in the case of successful insertion in the database. insert_sql is the sql insert statement. if data is ok this procedure will insert data into the database in a double click safe manner and will returnredirect to the page specified by return_url. if database insert fails, this procedure will return a sensible error message to the user.

Switches:
-bind (optional)
Parameters:
statement_name
table_name
id_column_name
generated_id
return_url
insert_dml
 

ad_decode (public)

ad_decode [ args... ]
this procedure is analogus to sql decode procedure. first parameter is the value we want to decode. this parameter is followed by a list of pairs where first element in the pair is convert from value and second element is convert to value. last value is default value, which will be returned in the case convert from values matches the given value to be decoded

 

ad_export_vars (public)

ad_export_vars [ -form ] [ -exclude exclude ] [ -override override ] \
    [ include ]
Deprecated.

Note This proc is deprecated in favor of export_vars. They're very similar, but export_vars have a number of advantages:

  • It can sign variables (the the :sign flag)
  • It can export variables as a :multiple.
  • It can export arrays with on-the-fly values (not pulled from the environment)
It doesn't have the foo(bar) syntax to pull a single value from an array, however, but you can do the same by saying export_vars {{foo.bar $foo(bar)}}.

Helps export variables from one page to the next, either as URL variables or hidden form variables. It'll reach into arrays and grab either all values or individual values out and export them in a way that will be consistent with the ad_page_contract :array flag.

Example:

doc_body_append [ad_export_vars { msg_id user(email) { order_by date } }]
will export the variable msg_id and the value email from the array user, and it will export a variable named order_by with the value date.

The args is a list of variable names that you want exported. You can name

  • a scalar varaible, foo,
  • the name of an array, bar, in which case all the values in that array will get exported, or
  • an individual value in an array, bar(baz)
  • a list in [array get] format { name value name value ..}. The value will get substituted normally, so you can put a computation in there.

A more involved example:

set my_vars { msg_id user(email) order_by }
doc_body_append [ad_export_vars -override { order_by $new_order_by } $my_vars]

Switches:
-form (boolean) (optional)
set this parameter if you want the variables exported as hidden form variables, as opposed to URL variables, which is the default.
-exclude (optional)
takes a list of names of variables you don't want exported, even though they might be listed in the args. The names take the same form as in the args list.
-override (optional)
takes a list of the same format as args, which will get exported no matter what you have excluded.
Parameters:
include (optional)
Author:
Lars Pind <lars@pinds.com>
Created:
21 July 2000

See Also:
 

ad_generate_random_string (public)

ad_generate_random_string [ length ]
Generates a random string made of numbers and letters

Parameters:
length (defaults to "8")
 

ad_get_cookie (public)

ad_get_cookie [ -include_set_cookies include_set_cookies ] name \
    [ default ]
Returns the value of a cookie, or $default if none exists.

Switches:
-include_set_cookies (defaults to "t") (optional)
Parameters:
name
default (optional)
 

ad_get_tcl_call_stack (public)

ad_get_tcl_call_stack [ level ]
Returns a stack trace from where the caller was called. See also ad_print_stack_trace which generates a more readable stack trace at the expense of truncating args.

Parameters:
level (defaults to "-2") - The level to start from, relative to this proc. Defaults to -2, meaning the proc that called this proc's caller.
Author:
Lars Pind <lars@pinds.com>

See Also:
 

ad_httpget (public)

ad_httpget [ -url url ] [ -headers headers ] [ -timeout timeout ] \
    [ -depth depth ]
Just like ns_httpget, but first headers is an ns_set of headers to send during the fetch. ad_httpget also makes use of Conditional GETs (if called with a Last-Modified header). Returns the data in array get form with array elements page status modified.

Switches:
-url (optional)
-headers (optional)
-timeout (defaults to "30") (optional)
-depth (defaults to "0") (optional)
 

ad_ns_set_keys (public)

ad_ns_set_keys [ -colon ] [ -exclude exclude ] set_id
Returns the keys of a ns_set as a Tcl list, like array names.

Switches:
-colon (boolean) (optional)
If set, will prepend all the keys with a colon; useful for bind variables
-exclude (optional)
Optional Tcl list of key names to exclude
Parameters:
set_id
Author:
Lars Pind <lars@pinds.com>
 

ad_ns_set_to_tcl_vars (public)

ad_ns_set_to_tcl_vars [ -duplicates duplicates ] [ -level level ] \
    set_id
Takes an ns_set and sets variables in the caller's environment correspondingly, i.e. if key is foo and value is bar, the Tcl var foo is set to bar.

Switches:
-duplicates (defaults to "overwrite") (optional)
This optional switch argument defines what happens if the Tcl var already exists, or if there are duplicate entries for the same key. overwrites just overwrites the var, which amounts to letting the ns_set win over pre-defined vars, and later entries in the ns_set win over earlier ones. ignore means the variable isn't overwritten. fail will make this proc fail with an error. This makes it easier to track subtle errors that could occur because of unpredicted name clashes.
-level (defaults to "1") (optional)
The level to upvar to.
Parameters:
set_id
Author:
Lars Pind <lars@pinds.com>
 

ad_return_top_of_page (public)

ad_return_top_of_page first_part_of_page [ content_type ]
Returns HTTP headers plus the top of the user-visible page.

Parameters:
first_part_of_page
content_type (defaults to "text/html")
 

ad_returnredirect (public)

ad_returnredirect [ -message message ] [ -html ] \
    [ -allow_complete_url ] target_url
Write the HTTP response required to get the browser to redirect to a different page, to the current connection. This does not cause execution of the current page, including serving an ADP file, to stop. If you want to stop execution of the page, you should call ad_script_abort immediately following this call.

This proc is a replacement for ns_returnredirect, but improved in two important respects:

  • When the supplied target_url isn't complete, (e.g. /foo/bar.tcl or foo.tcl) the prepended location part is constructed by looking at the HTTP 1.1 Host header.
  • If an URL relative to the current directory is supplied (e.g. foo.tcl) it prepends location and directory.

Switches:
-message (optional)
A message to display to the user. See util_user_message.
-html (boolean) (optional)
Set this flag if your message contains HTML. If specified, you're responsible for proper quoting of everything in your message. Otherwise, we quote it for you.
-allow_complete_url (boolean) (optional)
By default we disallow redirecting to urls outside the current host. This is based on the currently set host header or the host name in the config file if there is no host header. Set allow_complete_url if you are redirecting to a known safe external web site. This prevents redirecting to a site by URL query hacking.
Parameters:
target_url

See Also:
 

ad_schedule_proc (public)

ad_schedule_proc [ -thread thread ] [ -once once ] [ -debug debug ] \
    [ -all_servers all_servers ] [ -schedule_proc schedule_proc ] \
    interval proc [ args... ]
Replacement for ns_schedule_proc and friends, allowing us to track what's going on. Can be monitored via /admin/monitoring/schedule-procs.tcl. The procedure defaults to run on only the canonical server unless the all_servers flag is set to true.

Switches:
-thread (defaults to "f") (optional)
t/f If true run scheduled proc in its own thread
-once (defaults to "f") (optional)
t/f. If true only run the scheduled proc once
-debug (defaults to "f") (optional)
t/f If true log debugging information
-all_servers (defaults to "f") (optional)
If true run on all servers in a cluster
-schedule_proc (optional)
ns_schedule_daily, ns_schedule_weekly or blank
Parameters:
interval - If schedule_proc is empty, the interval to run the proc in seconds, otherwise a list of interval arguments to pass to ns_schedule_daily or ns_schedule_weekly
proc - The proc to schedule
 

ad_set_cookie (public)

ad_set_cookie [ -replace replace ] [ -secure secure ] \
    [ -expire expire ] [ -max_age max_age ] [ -domain domain ] \
    [ -path path ] name [ value ]
Sets a cookie.

Switches:
-replace (defaults to "f") (optional)
forces the current output headers to be checked for the same cookie. If the same cookie is set for a second time without the replace option being specified, the client will receive both copies of the cookie.
-secure (defaults to "f") (optional)
specifies to the user agent that the cookie should only be transmitted back to the server of secure transport.
-expire (defaults to "f") (optional)
specifies whether we should expire (clear) the cookie. Setting Max-Age to zero ought to do this, but it doesn't in some browsers (tested on IE 6).
-max_age (optional)
specifies the maximum age of the cookies in seconds (consistent with RFC 2109). max_age inf specifies cookies that never expire. The default behavior is to issue session cookies.
-domain (optional)
specifies the domain(s) to which this cookie applies. See RFC2109 for the semantics of this cookie attribute.
-path (defaults to "/") (optional)
specifies a subset of URLs to which this cookie applies. It must be a prefix of the URL being accessed.
Parameters:
name
value (optional) - is autmatically URL encoded.

See Also:
 

ad_set_typed_form_variable_filter (public)

ad_set_typed_form_variable_filter url_pattern [ args... ]
Deprecated.

    #
    # Register special rules for form variables.
    #
    # Example:
    #
    #    ad_set_typed_form_variable_filter /my_module/* {a_id number} {b_id word} {*_id integer}
    #
    # For all pages under /my_module, set_form_variables would set 
    # $a_id only if it was number, and $b_id only if it was a 'word' 
    # (a string that contains only letters, numbers, dashes, and 
    # underscores), and all other variables that match the pattern
    # *_id would be set only if they were integers.
    #
    # Variables not listed have no restrictions on them.
    #
    # By default, the three supported datatypes are 'integer', 'number',
    # and 'word', although you can add your own type by creating
    # functions named ad_var_type_check_${type_name}_p which should
    # return 1 if the value is a valid $type_name, or 0 otherwise.
    #
    # There's also a special datatype named 'nocheck', which will
    # return success regardless of the value. (See the docs for 
    # ad_var_type_check_${type_name}_p to see how this might be
    # useful.)
    #
    # The default data_type is 'integer', which allows you shorten the
    # command above to:
    #
    #    ad_set_typed_form_variable_filter /my_module/* a_id {b_id word}
    #

    ad_page_contract is the preferred mechanism to do automated
    validation of form variables.
    

Parameters:
url_pattern

See Also:
 

ad_tcl_list_list_to_ns_set (public)

ad_tcl_list_list_to_ns_set [ -set_id set_id ] [ -put ] kv_pairs
Takes a list of lists of key/value pairs and ns_set updates values in an ns_set.

Switches:
-set_id (optional)
If this switch is specified, it'll use this set instead of creating a new one.
-put (boolean) (optional)
If this boolean switch is specified, it'll use ns_set put instead of ns_set update (update is default)
Parameters:
kv_pairs - A list of lists containing key/value pairs to be stuffed into the ns_set
Author:
Yonatan Feldman <yon@arsdigita.com>
 

ad_tcl_vars_list_to_ns_set (public)

ad_tcl_vars_list_to_ns_set [ -set_id set_id ] [ -put ] vars_list
Takes a TCL list of variable names and ns_set updates values in an ns_set correspondingly: key is the name of the var, value is the value of the var. The caller is (obviously) responsible for freeing the set if need be.

Switches:
-set_id (optional)
If this switch is specified, it'll use this set instead of creating a new one.
-put (boolean) (optional)
If this boolean switch is specified, it'll use ns_set put instead of ns_set update (update is default)
Parameters:
vars_list
Author:
Lars Pind <lars@pinds.com>
 

ad_tcl_vars_to_ns_set (public)

ad_tcl_vars_to_ns_set [ -set_id set_id ] [ -put ] [ args... ]
Takes a list of variable names and ns_set updates values in an ns_set correspondingly: key is the name of the var, value is the value of the var. The caller is (obviously) responsible for freeing the set if need be.

Switches:
-set_id (optional)
If this switch is specified, it'll use this set instead of creating a new one.
-put (boolean) (optional)
If this boolean switch is specified, it'll use ns_set put instead of ns_set update (update is default)
Author:
Lars Pind <lars@pinds.com>
 

ad_urlencode (public)

ad_urlencode string
same as ns_urlencode except that dash and underscore are left unencoded.

Parameters:
string
 

ad_var_type_check_dirname_p (public)

ad_var_type_check_dirname_p value
    #
    # return 0 if $value contains a / or \, 1 otherwise.
    #
    
	

Parameters:
value
 

ad_var_type_check_fail_p (public)

ad_var_type_check_fail_p value
    #
    # A check that always returns 0. Useful if you want to disable all access
    # to a page.
    #
    
	

Parameters:
value
 

ad_var_type_check_integer_p (public)

ad_var_type_check_integer_p value
    #
    # return 1 if $value is an integer, 0 otherwise.
    #
    
	

Parameters:
value
 

ad_var_type_check_integerlist_p (public)

ad_var_type_check_integerlist_p value
    #
    # return 1 if list contains only numbers, spaces, and commas.
    # Example '5, 3, 1'. Note: it doesn't allow negative numbers,
    # because that could let people sneak in numbers that get
    # treated like math expressions like '1, 5-2'
    #
    #
    
	

Parameters:
value
 

ad_var_type_check_nocheck_p (public)

ad_var_type_check_nocheck_p [ value ]
    #
    # return 1 regardless of the value. This useful if you want to 
    # set a filter over the entire site, then create a few exceptions.
    #
    # For example:
    #
    #   ad_set_typed_form_variable_filter /my-dangerous-page.tcl {user_id nocheck}
    #   ad_set_typed_form_variable_filter /*.tcl user_id
    #
    

Parameters:
value (optional)
 

ad_var_type_check_noquote_p (public)

ad_var_type_check_noquote_p value
    #
    # return 1 if $value contains any single-quotes
    #
    
	

Parameters:
value
 

ad_var_type_check_number_p (public)

ad_var_type_check_number_p value
    #
    # return 1 if $value is a valid number
    #
    
	

Parameters:
value
 

ad_var_type_check_safefilename_p (public)

ad_var_type_check_safefilename_p value
    #
    # return 0 if the file contains ".."
    #
    
	

Parameters:
value
 

ad_var_type_check_third_urlv_integer_p (public)

ad_var_type_check_third_urlv_integer_p [ args ]
    #
    # Returns 1 if the third path element in the URL is integer.
    #
    
	

Parameters:
args (optional)
 

ad_var_type_check_word_p (public)

ad_var_type_check_word_p value
    #
    # return 1 if $value contains only letters, numbers, dashes, 
    # and underscores, otherwise returns 0.
    #
    

Parameters:
value
 

apply (public)

apply func arglist
Evaluates the first argument with ARGLIST as its arguments, in the environment of its caller. Analogous to the Lisp function of the same name.

Parameters:
func
arglist
 

check_for_form_variable_naughtiness (public)

check_for_form_variable_naughtiness name value
stuff to process the data that comes back from the users if the form looked like and then after you run this function you'll have Tcl vars $foo and $bar set to whatever the user typed in the form this uses the initially nauseating but ultimately delicious tcl system function "uplevel" that lets a subroutine bash the environment and local vars of its caller. It ain't Common Lisp... This is an ad-hoc check to make sure users aren't trying to pass in "naughty" form variables in an effort to hack the database by passing in SQL. It is called in all instances where a Tcl variable is set from a form variable. Checks the given variable for against known form variable exploits. If it finds anything objectionable, it throws an error.

Parameters:
name
value
 

db_html_select_options (public)

db_html_select_options [ -bind bind ] [ -select_option select_option ] \
    stmt_name sql
Generate html option tags for an html selection widget. If select_option is passed, this option will be marked as selected.

Switches:
-bind (optional)
-select_option (optional)
Parameters:
stmt_name
sql
Author:
yon [yon@arsdigita.com]
 

db_html_select_value_options (public)

db_html_select_value_options [ -bind bind ] \
    [ -select_option select_option ] [ -value_index value_index ] \
    [ -option_index option_index ] stmt_name sql
Generate html option tags with values for an html selection widget. if select_option is passed and there exists a value for it in the values list, this option will be marked as selected. select_option can be passed a list, in which case all options matching a value in the list will be marked as selected.

Switches:
-bind (optional)
-select_option (defaults to "[list]") (optional)
-value_index (defaults to "0") (optional)
-option_index (defaults to "1") (optional)
Parameters:
stmt_name
sql
Author:
yon [yon@arsdigita.com]
 

exists_and_equal (public)

exists_and_equal varname value
Returns 1 if the variable name exists in the caller's envirnoment and is equal to the given value.

Parameters:
varname
value
Author:
Peter Marklund

See Also:
 

exists_and_not_null (public)

exists_and_not_null varname
Returns 1 if the variable name exists in the caller's environment and is not the empty string. Note you should enter the variable name, and not the variable value (varname not $varname which will pass variable varnames value into this function).

Parameters:
varname
 

export_entire_form (public)

export_entire_form
Exports everything in ns_getform to the ns_set. This should generally not be used. It's much better to explicitly name the variables you want to export. export_vars is now the prefered interface.


See Also:
 

export_entire_form_as_url_vars (public)

export_entire_form_as_url_vars [ vars_to_passthrough ]
export_vars is now the prefered interface. Returns a URL parameter string of name-value pairs of all the form parameters passed to this page. If vars_to_passthrough is given, it should be a list of parameter names that will be the only ones passed through.

Parameters:
vars_to_passthrough (optional)

See Also:
 

export_form_vars (public)

export_form_vars [ -sign ] [ args... ]
Deprecated.

Exports a number of variables as hidden input fields in a form. Specify a list of variable names. The proc will reach up in the caller's name space to grab the value of the variables. Variables that are not defined are silently ignored. You can append :multiple to the name of a variable. In this case, the value will be treated as a list, and each of the elements output separately.

export_vars is now the prefered interface.

Example usage: [export_form_vars -sign foo bar:multiple baz]

Switches:
-sign (boolean) (optional)
If this flag is set, all the variables output will be signed using ad_sign. These variables should then be verified using the :verify flag to ad_page_contract, which in turn uses ad_verify_signature. This ensures that the value hasn't been tampered with at the user's end.

See Also:
 

export_ns_set_vars (public)

export_ns_set_vars [ format ] [ exclusion_list ] [ setid ]
Returns all the params in an ns_set with the exception of those in exclusion_list. If no setid is provide, ns_getform is used. If format = url, a url parameter string will be returned. If format = form, a block of hidden form fragments will be returned. export_vars is now the prefered interface.

Parameters:
format (defaults to "url") - either url or form
exclusion_list (optional) - list of fields to exclude
setid (optional) - if null then it is ns_getform

See Also:
 

export_url_vars (public)

export_url_vars [ -sign ] [ args... ]
export_vars is now the prefered interface. Returns a string of key=value pairs suitable for inclusion in a URL; you can pass it any number of variables as arguments. If any are defined in the caller's environment, they are included. See also export_entire_form_as_url_vars.

Instead of naming a variable you can also say name=value. Note that the value here is not the name of a variable but the literal value you want to export e.g., export_url_vars [ns_urlencode foo]=[ns_urlencode $the_value].

For normal variables, you can say export_url_vars foo:multiple. In this case, the value of foo will be treated as a Tcl list, and each value will be output separately e.g., foo=item0&foo=item1&foo=item2...

You cannot combine the foo=bar syntax with the foo:multiple syntax. Why? Because there's no way we can distinguish between the :multiple being part of the value of foo or being a flag intended for export_url_vars.

Switches:
-sign (boolean) (optional)
If this flag is set, all the variables output will be signed using ad_sign. These variables should then be verified using the :verify flag to ad_page_contract, which in turn uses ad_verify_signature. This ensures that the value hasn't been tampered with at the user's end.

See Also:
 

export_vars (public)

export_vars [ -sign ] [ -form ] [ -url ] [ -quotehtml ] \
    [ -entire_form ] [ -no_empty ] [ -base base ] [ -anchor anchor ] \
    [ -exclude exclude ] [ -override override ] [ vars ]
Exports variables either in URL or hidden form variable format. It should replace export_form_vars, export_url_vars and all their friends.

Example usage: [export_vars -form { foo bar baz }]

This will export the three variables foo, bar and baz as hidden HTML form fields. It does exactly the same as [export_form_vars foo bar baz].

Example usage: [export_vars -url -sign -override {{foo "new value"}} -exclude { bar } { foo bar baz }]

This will export a variable named foo with the value "new value" and a variable named baz with the value of baz in the caller's environment. Since we've specified that bar should be excluded, bar won't get exported even though it's specified in the last argument. Additionally, even though foo is specified also in the last argument, the value we use is the one given in the override argument. Finally, both variables are signed, because we specified the -sign switch.

You can specify variables with three different precedences, namely override, exclude or vars. If a variable is present in override, that's what'll get exported, no matter what. If a variable is in exclude and not in override, then it will not get output. However, if it is in vars and not in either of override or exclude, then it'll get output. In other words, we check override, exclude and vars in that order of precedence.

The two variable specs, vars and override both look the same: They take a list of variable specs. Examples of variable specs are:

  • foo
  • foo:multiple,sign
  • {foo "the value"}
  • {foo {[my_function arg]}}
  • {foo:array,sign {[array get my_array]}}
In general, there's one or two elements. If there are two, the second element is the value we should use. If one, we pull the value from the variable of the same name in the caller's environment. Note that when you specify the value directly here, we call subst on it, so backslashes, square brackets and variables will get substituted correctly. Therefore, make sure you use curly braces to surround this instead of the [list] command; otherwise the contents will get substituted twice, and you'll be in trouble.

Right after the name, you may specify a colon and some flags, separated by commas. Valid flags are:

multiple
Treat the value as a list and output each element separately.
array
The value is an array and should be exported in a way compliant with the :array flag of ad_page_contract, which means that each entry will get output as name.key=value.

If you don't specify a value directly, but want it pulled out of the Tcl environment, then you don't need to specify :array. If you do, and the variable is in fact not an array, an error will be thrown.

sign
Sign this variable. This goes hand-in-hand with the :verify flag of ad_page_contract and makes sure that the value isn't tampered with on the client side. The -sign switch to export_vars, is a short-hand for specifying the :sign switch on every variable.
The argument exclude simply takes a list of names of variables that you don't want exported, even though they're specified in vars.

Intended use: A page may have a set of variables that it cares about. You can store this in a variable once and pass that to export_vars like this:

set my_vars { user_id sort_by filter_by }
... [export_vars $my_vars] ...

Then, say one of them contains a column to filter on. When you want to clear that column, you can say [export_vars -exclude { filter_by } $my_vars].

Similarly, if you want to change the sort order, you can say [export_vars -override { { sort_by $column } } $my_vars], and sorting will be done according to the new value of column.

If the variable name contains a colon (:), that colon must be escaped with a backslash, so for example "form:id" becomes "form\:id". Sorry.

Switches:
-sign (boolean) (optional)
Sign all variables.
-form (boolean) (optional)
Export in form format. You can't specify both URL and form format.
-url (boolean) (optional)
Export in URL format. This is the default.
-quotehtml (boolean) (optional)
HTML quote the entire resulting string. This is an interim solution while we're waiting for the templating system to do the quoting for us.
-entire_form (boolean) (optional)
Export the entire form from the GET query string or the POST.
-no_empty (boolean) (optional)
-base (optional)
-anchor (optional)
-exclude (optional)
-override (optional)
Parameters:
vars (optional)
Options:
-no_empty
If specified, variables with an empty string value will be suppressed from being exported. This avoids cluttering up the URLs with lots of unnecessary variables.
-base
The base URL to make a link to. This will be prepended to the query string along with a question mark (?), if the query is non-empty. so the returned string can be used directly in a link. This is only relevant to URL export.
Author:
Lars Pind <lars@pinds.com>
Created:
December 7, 2000
 

get_referrer (public)

get_referrer
gets the Referer for the headers

 

lmap (public)

lmaplist proc_name
Applies proc_name to each item of the list, appending the result of each call to a new list that is the return value.

Parameters:
list
proc_name
 

max (public)

max[ args... ]
Returns the maximum of a list of numbers. Example: max 2 3 1.5 returns 3.

Author:
Lars Pind <lars@pinds.com>
Created:
31 August 2000
 

merge_form_with_query (public)

merge_form_with_query [ -bind bind ] form statement_name sql_qry
Merges a form with a query string.

Switches:
-bind (optional)
A ns_set stuffed with bind variables for the sql_qry.
Parameters:
form - the form to be stuffed.
statement_name - An identifier for the sql_qry to be executed.
sql_qry - The sql that must be executed.
 

min (public)

min[ args... ]
Returns the minimum of a list of numbers. Example: min 2 3 1.5 returns 1.5.

Author:
Ken Mayer <kmayer@bitwrangler.com>
Created:
26 September 2002
 

random (public)

random
Return a pseudo-random number between 0 and 1.

 

randomInit (public)

randomInit seed
seed the random number generator.

Parameters:
seed
 

randomRange (public)

randomRange range
Returns a pseudo-random number between 0 and range.

Parameters:
range
Returns:
integer
 

remove_nulls_from_ns_set (public)

remove_nulls_from_ns_set old_set_id
Creates and returns a new ns_set without any null value fields

Parameters:
old_set_id
Returns:
new ns_set
 

safe_eval (public)

safe_eval [ args... ]
Version of eval that checks its arguments for brackets that may be used to execute unsafe code.

 

util::age_pretty (public)

util::age_pretty -timestamp_ansi timestamp_ansi \
    -sysdate_ansi sysdate_ansi [ -hours_limit hours_limit ] \
    [ -days_limit days_limit ] [ -mode_2_fmt mode_2_fmt ] \
    [ -mode_3_fmt mode_3_fmt ] [ -locale locale ]
Formats past time intervals in one of three different modes depending on age. The first mode is "1 hour 3 minutes" and is NOT currently internationalized. The second mode is e.g. "14:10, Thursday" and is internationalized. The third mode is "14:10, 01 Mar 2001" and is internationalized. Both the locale and the exact format string for modes 2 and 3 can be overridden by parameters. (Once mode 1 is i18nd, the following sentence will be true:'In mode 1, only the locale can be overridden.' Until then, move along. These aren't the timestamps you're looking for.)

Switches:
-timestamp_ansi (required)
The older timestamp in full ANSI: YYYY-MM-DD HH24:MI:SS
-sysdate_ansi (required)
The newer timestamp.
-hours_limit (defaults to "12") (optional)
The upper limit, in hours, for mode 1.
-days_limit (defaults to "3") (optional)
The upper limit, in days, for mode 2.
-mode_2_fmt (defaults to "%X, %A") (optional)
A formatting string, as per lc_time_fmt, for mode 2
-mode_3_fmt (defaults to "%X, %d %b %Y") (optional)
A formatting string, as per lc_time_fmt, for mode 3
-locale (optional)
If present, overrides the default locale
Returns:
Interval between timestamp and sysdate, as localized text string.
 

util::array_list_spec_pretty (public)

util::array_list_spec_pretty list [ indent ]
Pretty-format an array-list spec with proper indentation.

Parameters:
list
indent (defaults to "0")
 

util::backup_file (public)

util::backup_file -file_path file_path \
    [ -backup_suffix backup_suffix ]
Backs up (move) the file or directory with given path to a file/directory with a backup suffix. Will avoid overwriting old backup files by adding a number to the filename to make it unique. For example, suppose you are backing up /web/my-server/packages/my-package/file.txt and the file has already been backed up to /web/my-server/packages/my-package/file.txt.bak. Invoking this proc will then generate the backup file /web/my-server/packages/my-package/file.txt.bak.2

Switches:
-file_path (required)
-backup_suffix (defaults to ".bak") (optional)
The suffix to add to the backup file.
Author:
Peter Marklund
 

util::catch_exec (public)

util::catch_exec command result_var
Catch a call to Tcl exec. Handle shell return codes consistently. Works like catch. The result of the exec is put into the variable named in result_var. Inspired by http://wiki.tcl.tk/1039

Parameters:
command - A list of arguments to pass to exec
result_var - Variable name in caller's scope to set the result in
Returns:
0 or 1. 0 if no error, 1 if an error occured. If an error occured the error message will be put into result_var in the caller's scope.
Author:
Dave Bauer
Created:
2008-01-28
 

util::cookietime (public)

util::cookietime time
Return an RFC2109 compliant string for use in "Expires".

Parameters:
time
 

util::external_url_p (public)

util::external_url_p url
check if this URL is external to the current host or a valid alternative valid alternatives include HTTPS or HTTP protocol change HTTP or HTTPS port number added or removed from current host name

Parameters:
url
 

util::find_all_files (public)

util::find_all_files [ -include_dirs include_dirs ] \
    [ -max_depth max_depth ] [ -check_file_func check_file_func ] \
    [ -extension extension ] -path path
Returns a list of lists with full paths and filename to all files under $path in the directory tree (descending the tree to a depth of up to $max_depth). Clients should not depend on the order of files returned. DOES NOT WORK ON WINDOWS (you have to change the splitter and I don't know how to detect a windows system)

Switches:
-include_dirs (defaults to "0") (optional)
Should directories be included in the list of files.
-max_depth (defaults to "1") (optional)
How many levels of directories should be searched. Defaults to 1 which is the current directory
-check_file_func (optional)
Function which can be executed upon the file to determine if it is worth the effort
-extension (optional)
Only return files with this extension (single value !)
-path (required)
The path in which to search for the files. Note that this is an absolute Path
Returns:
list of lists (filename and full_path) of all files found.
 

util::interval_pretty (public)

util::interval_pretty [ -seconds seconds ]
Takes a number of seconds and returns a pretty interval of the form "3h 49m 13s"

Switches:
-seconds (defaults to "0") (optional)
 

util::random_list_element (public)

util::random_list_element list
Returns a random element from the list.

Parameters:
list
 

util::randomize_list (public)

util::randomize_list list
Returns a random permutation of the list.

Parameters:
list
 

util::roll_server_log (public)

util::roll_server_log
Invoke the AOLserver ns_logroll command with some bookend log records. This rolls the error log, not the access log.

 

util::string_check_urlsafe (public)

util::string_check_urlsafe s1
This proc accepts a string and verifies if it is url safe. - make sure there is no space - make sure there is no special characters except '-' or '_' Returns 1 if yes and 0 if not. Meant to be used in the validation section of ad_form.

Parameters:
s1
 

util::string_length_compare (public)

util::string_length_compare s1 s2
String length comparison function for use with lsort's -command switch.

Parameters:
s1
s2
 

util::subst_safe (public)

util::subst_safe string
Make string safe for subst'ing.

Parameters:
string
 

util::which (public)

util::which prog

Parameters:
prog - name of the program to be located on the search path
Returns:
fully qualified name including path, when specified program is found, or otherwise empty string
Author:
Gustaf Neumann Use environment variable PATH to search for the specified executable program. Replacement for UNIX command "which", avoiding exec. exec which: 3368.445 microseconds per iteration ::util::which: 282.372 microseconds per iteration In addition of being more than 10 time faster than the version via exec, this version is less platform dependent.
 

util::word_diff (public)

util::word_diff -old old -new new [ -split_by split_by ] \
    [ -filter_proc filter_proc ] [ -start_old start_old ] \
    [ -end_old end_old ] [ -start_new start_new ] [ -end_new end_new ]
Does a word (or character) diff on two lines of text and indicates text that has been deleted/changed or added by enclosing it in start/end_old/new.

Switches:
-old (required)
The original text.
-new (required)
The modified text.
-split_by (optional)
If split_by is a space, the diff will be made on a word-by-word basis. If it is the empty string, it will be made on a char-by-char basis.
-filter_proc (defaults to "ad_quotehtml") (optional)
A filter to run the old/new text through before doing the diff and inserting the HTML fragments below. Keep in mind that if the input text is HTML, and the start_old, etc... fragments are inserted at arbitrary locations depending on where the diffs are, you might end up with invalid HTML unless the original HTML is quoted.
-start_old (defaults to "") (optional)
HTML fragment to place before text that has been removed.
-end_old (defaults to "") (optional)
HTML fragment to place after text that has been removed.
-start_new (defaults to "") (optional)
HTML fragment to place before new text.
-end_new (defaults to "") (optional)
HTML fragment to place after new text.
Author:
Gabriel Burca

See Also:
 

util_AnsiDatetoPrettyDate (public)

util_AnsiDatetoPrettyDate sql_date
Converts 1998-09-05 to September 5, 1998

Parameters:
sql_date
 

util_PrettyTclBoolean (public)

util_PrettyTclBoolean zero_or_one
Turns a 1 (or anything else that makes a Tcl IF happy) into Yes; anything else into No

Parameters:
zero_or_one
 

util_ReturnMetaRefresh (public)

util_ReturnMetaRefresh url [ seconds_delay ]
Ugly workaround to deal with IE5.0 bug handling multipart/form-data using Meta Refresh page instead of a redirect.

Parameters:
url
seconds_delay (defaults to "0")
 

util_absolute_path_p (public)

util_absolute_path_p path
Check whether the path begins with a slash

Parameters:
path
 

util_background_exec (public)

util_background_exec [ -pass_vars pass_vars ] -name name code_chunk
Executes a chunk of code in the background. The code is run exclusively, meaning that no two threads with the same name can run at the same time.

Switches:
-pass_vars (optional)
Names of variables which you want passed to the code chunk
-name (required)
The name of the thread. No two chunks with the same name can run at the same time.
Parameters:
code_chunk - The chunk you want executed
 

util_background_get_result (public)

util_background_get_result -name name
Gets the result of a completed background thread execution.

Switches:
-name (required)
 

util_background_reset (public)

util_background_reset -name name
Gets the result of a completed background thread execution.

Switches:
-name (required)
 

util_background_running_p (public)

util_background_running_p -name name

Switches:
-name (required)
 

util_commify_number (public)

util_commify_number num
Returns the number with commas inserted where appropriate. Number can be positive or negative and can have a decimal point. e.g. -1465.98 => -1,465.98

Parameters:
num
 

util_complete_url_p (public)

util_complete_url_p string
Determine whether string is a complete URL, i.e. wheteher it begins with protocol: where protocol consists of letters only.

Parameters:
string
 

util_current_directory (public)

util_current_directory
Returns the directory of the current URL.

We can't just use [file dirname [ad_conn url]] because we want /foo/bar/ to return /foo/bar/ and not /foo .

Also, we want to return directory WITH the trailing slash so that programs that use this proc don't have to treat the root directory as a special case.

 

util_current_location (public)

util_current_location
Like ad_conn location - Returns the location string of the current request in the form protocol://hostname[:port] but it looks at the Host header, that is, takes into account the host name the client used although it may be different from the host name from the server configuration file. If the Host header is missing or empty util_current_location falls back to ad_conn location. cro@ncacasi.org 2002-06-07 Note: IE fouls up the Host header if a server is on a non-standard port; it does not change the port number when redirecting to https. So we would get redirects from http://some-host:8000 to https://some-host:8000

Authors:
Lars Pind <lars@collaboraid.biz>
Peter Marklund
 

util_driver_info (public)

util_driver_info -array array [ -driver driver ]
Returns the protocol and port for the specified driver.

Switches:
-array (required)
the array to populate with proto and port
-driver (optional)
the driver to query (defaults to [ad_conn driver])
 

util_email_unique_p (public)

util_email_unique_p email
Returns 1 if the email passed in does not yet exist in the system.

Parameters:
email
Author:
yon <yon@openforce.net>
 

util_email_valid_p (public)

util_email_valid_p query_email
Returns 1 if an email address has more or less the correct form. The regexp was taken from Jeff Friedls book "Mastering Regular Expressions".

Parameters:
query_email
Authors:
Philip Greenspun <philg@mit.edu>
Jeff Friedl <jfriedl@oreilly.com>
Lars Pind <lars@arsdigita.com>
 

util_escape_quotes_for_csv (public)

util_escape_quotes_for_csv string
Returns its argument with double quote replaced by backslash double quote

Parameters:
string
 

util_get_current_url (public)

util_get_current_url
Returns a URL for re-issuing the current request, with query variables. If a form submission is present, that is converted into query vars as well.

Returns:
URL for the current page
Author:
Lars Pind <lars@pinds.com>
Created:
February 11, 2003
 

util_get_http_status (public)

util_get_http_status url [ use_get_p ] [ timeout ]
Returns the HTTP status code, e.g., 200 for a normal response or 500 for an error, of a URL. By default this uses the GET method instead of HEAD since not all servers will respond properly to a HEAD request even when the URL is perfectly valid. Note that this means AOLserver may be sucking down a lot of bits that it doesn't need.

Parameters:
url
use_get_p (defaults to "1")
timeout (defaults to "30")
 

util_get_subset_missing (public)

util_get_subset_missing list1 list2
Returns the elements in list1 that are not in list2. Ignores duplicates.

Parameters:
list1
list2
Returns:
The list of elements from list1 that could not be found in list2.
Author:
Peter Marklund
 

util_get_user_messages (public)

util_get_user_messages [ -keep ] -multirow multirow
Gets and clears the message to be displayed on the next page load.

Switches:
-keep (boolean) (optional)
If set, then we will not clear the list of messages after getting them. Normal behavior is to clear them, so we only display the same messages once.
-multirow (required)
Name of a multirow in the current template namespace where you want the user messages set. The multirow will have one column, which is 'message'.

See Also:
 

util_http_file_upload (public)

util_http_file_upload [ -file file ] [ -data data ] [ -binary ] \
    [ -filename filename ] [ -name name ] [ -mime_type mime_type ] \
    [ -mode mode ] [ -rqset rqset ] url [ formvars ] [ timeout ] \
    [ depth ] [ http_referer ]
Implement client-side HTTP file uploads as multipart/form-data as per RFC 1867.

Similar to util_httppost, but enhanced to be able to upload a file as multipart/form-data. Also useful for posting to forms that require their input to be encoded as multipart/form-data instead of as application/x-www-form-urlencoded.

The switches -file /path/to/file and -data $raw_data are mutually exclusive. You can specify one or the other, but not both. NOTE: it is perfectly valid to not specify either, in which case no file is uploaded, but form variables are encoded using multipart/form-data instead of the usual encoding (as noted aboved).

If you specify either -file or -data you must supply a value for -name, which is the name of the <INPUT TYPE="file" NAME="..."> form tag.

Specify the -binary switch if the file (or data) needs to be base-64 encoded. Not all servers seem to be able to handle this. (For example, http://mol-stage.usps.com/mml.adp, which expects to receive an XML file doesn't seem to grok any kind of Content-Transfer-Encoding.)

If you specify -file then -filename is optional (it can be infered from the name of the file). However, if you specify -data then it is mandatory.

If -mime_type is not specified then ns_guesstype is used to try and find a mime type based on the filename. If ns_guesstype returns */* the generic value of application/octet-stream will be used.

Any form variables may be specified in one of four formats:

  • array (list of key value pairs like what [array get] returns)
  • formvars (list of url encoded formvars, i.e. foo=bar&x=1)
  • ns_set (an ns_set containing key/value pairs)
  • vars (a list of tcl vars to grab from the calling enviroment)

-rqset specifies an ns_set of extra headers to send to the server when doing the POST.

timeout, depth, and http_referer are optional, and are included as optional positional variables in the same order they are used in util_httppost. NOTE: util_http_file_upload does not (currently) follow any redirects, so depth is superfulous.

Switches:
-file (optional)
-data (optional)
-binary (boolean) (optional)
-filename (optional)
-name (optional)
-mime_type (defaults to "*/*") (optional)
-mode (defaults to "formvars") (optional)
-rqset (optional)
Parameters:
url
formvars (optional)
timeout (defaults to "30")
depth (defaults to "10")
http_referer (optional)
Author:
Michael A. Cleverly <michael@cleverly.com>
Created:
3 September 2002
 

util_httpget (public)

util_httpget url [ headers ] [ timeout ] [ depth ]
util_httpget simply calls ad_httpget which also returns status and last_modfied

Parameters:
url
headers (optional)
timeout (defaults to "30")
depth (defaults to "0")

See Also:
 

util_httpopen (public)

util_httpopen method url [ rqset ] [ timeout ] [ http_referer ]
Like ns_httpopen but works for POST as well; called by util_httppost

Parameters:
method
url
rqset (optional)
timeout (defaults to "30")
http_referer (optional)
 

util_httppost (public)

util_httppost url formvars [ timeout ] [ depth ] [ http_referer ]
Returns the result of POSTing to another Web server or -1 if there is an error or timeout. formvars should be in the form \"arg1=value1&arg2=value2\".

post is encoded as application/x-www-form-urlencoded. See util_http_file_upload for file uploads via post (encoded multipart/form-data).

Parameters:
url
formvars
timeout (defaults to "30")
depth (defaults to "0")
http_referer (optional)

See Also:
 

util_link_responding_p (public)

util_link_responding_p url [ list_of_bad_codes ]
Returns 1 if the URL is responding (generally we think that anything other than 404 (not found) is okay).

Parameters:
url
list_of_bad_codes (defaults to "404")

See Also:
 

util_list_of_ns_sets_to_list_of_lists (public)

util_list_of_ns_sets_to_list_of_lists -list_of_ns_sets list_of_ns_sets
Transform a list of ns_sets (most likely produced by db_list_of_ns_sets) into a list of lists that match the array set format in the sublists (key value key value ...)

Switches:
-list_of_ns_sets (required)
Author:
Ola Hansson <ola@polyxena.net>
Created:
September 27, 2002
 

util_list_to_ns_set (public)

util_list_to_ns_set aList
Convert a list in the form "key value key value ..." into a ns_set.

Parameters:
aList - The list to convert
Returns:
The id of a (non-persistent) ns_set
 

util_ns_set_to_list (public)

util_ns_set_to_list -set set
Convert an ns_set into a list suitable for passing in to the "array set" command (key value key value ...).

Switches:
-set (required)
The ns_set to convert
Returns:
An array of equivalent keys and values as the ns_set specified.
 

util_report_library_entry (public)

util_report_library_entry [ extra_message ]
Should be called at beginning of private Tcl library files so that it is easy to see in the error log whether or not private Tcl library files contain errors.

Parameters:
extra_message (optional)
 

util_report_successful_library_load (public)

util_report_successful_library_load [ extra_message ]
Should be called at end of private Tcl library files so that it is easy to see in the error log whether or not private Tcl library files contain errors.

Parameters:
extra_message (optional)
 

util_search_list_of_lists (public)

util_search_list_of_lists list_of_lists query_string \
    [ sublist_element_pos ]
Returns position of sublist that contains QUERY_STRING at SUBLIST_ELEMENT_POS.

Parameters:
list_of_lists
query_string
sublist_element_pos (defaults to "0")
 

util_sets_equal_p (public)

util_sets_equal_p list1 list2
Tests whether each unique string in list1 occurs as many times in list1 as in list2 and vice versa (regarless of order).

Parameters:
list1
list2
Returns:
1 if the lists have identical sets and 0 otherwise
Author:
Peter Marklund
 

util_subset_p (public)

util_subset_p list1 list2
Tests whether list1 is a subset of list2.

Parameters:
list1
list2
Returns:
1 if list1 is a subset of list2.
Author:
Peter Marklund
 

util_text_to_url (public)

util_text_to_url [ -existing_urls existing_urls ] [ -no_resolve ] \
    [ -replacement replacement ] [ -text text ] [ _text ]
Modify a string so that it is suited as a well formatted URL path element. Also, if given a list of existing urls it can catch duplicate or optionally create an unambiguous url by appending a dash and a digit.

Examples:
util_text_to_url -text "Foo Bar" returns foo-bar
util_text_to_url -existing_urls {foo-bar some-other-item} -text "Foo Bar" returns foo-bar-2

Switches:
-existing_urls (optional)
a list of URLs that already exist on the same level and would cause a conflict
-no_resolve (boolean) (optional)
Specify this flag if you do not want util_text_to_url to automatically generate "foo-bar-2" if "foo-bar" is already in existing_urls, and would rather have an error thrown.
-replacement (defaults to "-") (optional)
the character that is used to replace illegal characters
-text (optional)
the text to modify, e.g. "Foo Bar"
Parameters:
_text (optional) - the text to modify, e.g. "Foo Bar" (Deprecated, use -text instead. Fails when the value starts with a dash.)
Author:
Tilmann Singer
 

util_unlist (public)

util_unlist list [ args... ]
Places the nth element of list into the variable named by the nth element of args.

Parameters:
list
 

util_url_valid_p (public)

util_url_valid_p query_url
Returns 1 if a URL is a web URL (HTTP, HTTPS or FTP).

Parameters:
query_url
Author:
Philip Greenspun <philg@mit.edu>
 

util_user_message (public)

util_user_message [ -replace ] [ -html ] [ -message message ]
Sets a message to be displayed on the next page request.

Switches:
-replace (boolean) (optional)
Set this if you want to replace existing messages. Default behavior is to append to a list of messages.
-html (boolean) (optional)
Set this flag if your message contains HTML. If specified, you're responsible for proper quoting of everything in your message. Otherwise, we quote it for you.
-message (optional)
The message to display.

See Also:
 

util_wrap_list (public)

util_wrap_list [ -eol eol ] [ -indent indent ] [ -length length ] \
    items
Wraps text to a particular line length.

Switches:
-eol (defaults to " \") (optional)
the string to be used at the end of each line.
-indent (defaults to "4") (optional)
the number of spaces to use to indent all lines after the first.
-length (defaults to "70") (optional)
the maximum line length.
Parameters:
items - the list of items to be wrapped. Items are HTML-formatted. An individual item will never be wrapped onto separate lines.
 

validate_ad_dateentrywidget (public)

validate_ad_dateentrywidget field_name column form [ allow_null ]
Deprecated.

validate via ad_page_contract

Parameters:
field_name
column
form
allow_null (defaults to "0")

See Also:
 

validate_integer (public)

validate_integer field_name string
Deprecated.

Throws an error if the string isn't a decimal integer; otherwise strips any leading zeros (so this won't work for octals) and returns the result.

validate via ad_page_contract

Parameters:
field_name
string

See Also:
 

validate_zip_code (public)

validate_zip_code field_name zip_string country_code
Deprecated.

Given a string, signals an error if it's not a legal zip code

validate via ad_page_contract

Parameters:
field_name
zip_string
country_code

See Also:
 

value_if_exists (public)

value_if_exists var_name
If the specified variable exists in the calling environment, returns the value of that variable. Otherwise, returns the empty_string.

Parameters:
var_name
 

with_catch (public)

with_catch error_var body on_error
execute code in body with the catch errorMessage in error_var and if there is a non-zero return code from body execute the on_error block.

Parameters:
error_var
body
on_error
 

with_finally (public)

with_finally -code code -finally finally
Execute CODE, then execute cleanup code FINALLY. If CODE completes normally, its value is returned after executing FINALLY. If CODE exits non-locally (as with error or return), FINALLY is executed anyway.

Switches:
-code (required)
Code to be executed that could throw and error
-finally (required)
Cleanup code to be executed even if an error occurs
 

xml_get_child_node_attribute_by_path (public)

xml_get_child_node_attribute_by_path node path_list attribute_name
Return the attribute of a child node down a give path from the current node.

Example:

    set tree [xml_parse -persist "
<enterprise>
  <properties>
    <datasource>University of Durham: SIS</datasource>
    <target>University of Durham: LMS</target>
    <type>CREATE</type>
    <datetime>2001-08-08</datetime>
  </properties>
  <group recstatus = "1">
    <sourcedid>
      <source>University of Durham</source>
      <id>CS1</id>
    </sourcedid>
    <grouptype>
      <scheme>University of Durham</scheme>
      <typevalue level = "2"/>
    </grouptype>

    .....

  </group>
</enterprise>

"]
    set root_node [xml_doc_get_first_node $tree]
    set group_node [xml_node_get_children_by_name $root_node "group"] 
    set typevalue [xml_get_child_node_attribute_by_path $group_node {grouptype typevalue} "level"]
	

Parameters:
node - The node to start from
path_list - List of the node to try, e.g. { grouptype typevalue }.
attribute_name - Attribute name at the very end of the very botton of the tree route at path_list.
Author:
Rocael Hernandez <roc@viaro.net>
 

xml_get_child_node_content_by_path (public)

xml_get_child_node_content_by_path node path_list
Return the first non-empty contents of a child node down a given path from the current node.

Example:

set tree [xml_parse -persist {
    <enterprise>
      <properties>
        <datasource>Dunelm Services Limited</datasource>
        <target>Telecommunications LMS</target>
        <type>DATABASE UPDATE</type>
        <datetime>2001-08-08</datetime>
      </properties>
      <person recstatus = "1">
        <comments>Add a new Person record.</comments>
        <sourcedid>
          <source>Dunelm Services Limited</source>
          <id>CK1</id>
        </sourcedid>
        <name>
          <fn>Clark Kent</fn>
          <sort>Kent, C</sort>
          <nickname>Superman</nickname>
        </name>
        <demographics>
          <gender>2</gender>
        </demographics>
        <adr>
          <extadd>The Daily Planet</extadd>
          <locality>Metropolis</locality>
          <country>USA</country>
        </adr>
      </person>
    </enterprise>
}]

set root_node [xml_doc_get_first_node $tree]

aa_equals "person -> name -> nickname is Superman"  [xml_get_child_node_content_by_path $root_node { { person name nickname } }] "Superman"

aa_equals "Same, but after trying a couple of non-existent paths or empty notes"  [xml_get_child_node_content_by_path $root_node { { does not exist } { properties } { person name nickname } { person sourcedid id } }] "Superman"
aa_equals "properties -> datetime"  [xml_get_child_node_content_by_path $root_node { { person commments foo } { person name first_names } { properties datetime } }] "2001-08-08"

Parameters:
node - The node to start from
path_list - List of list of nodes to try, e.g. { { user_id } { sourcedid id } }, or { { name given } { name fn } }.
Author:
Lars Pind <lars@collaboraid.biz>