/NS/Admin
is bound to a Tcl script that generates and returns a server administration page. These functions (or scripts) are called operations.
/extend/myop
, or an entire hierarchy of URLs. Registering a hierarchy of URLs is useful for common operations that need to service requests for multiple URLs rooted at the same base URL. For example, a single Tcl script handles a URL that starts at /NS/Db/GetSearchForm
. The names of the database pool and database table for which to generate the search form are specified as the fourth and fifth elements of the URL path, for example: /NS/Db/GetSearchForm/nsdbpool/employees
.nsdbpool
and employees
parts of the URL are arguments to the operation. In this case, where the pool and table names are part of the URL, individual permission records can be set for different tables. For example, you may add a record to restrict the /NS/Db/GetSearchForm/nsdbpool/employees
URL so only system users may access the search form for a table of employees.* The permission records for other search forms are unaffected by this permission record. Most likely, they inherit their records from the /NS/GetSearchForm
record or perhaps the /NS
or /
records.Another way to send an argument to an operation function is to append the argument as a URL query string, separated from the URL by a single question mark (?). For example, the operation function above could have been (but was not) written to find the table name as a query string argument and the URL would have taken the form /NS/Db/GetSearchForm?employees. In this case, where the query string specifies the operation's arguments, only one record can specify the permissions for all possible table search forms. The query string is ignored for permission purposes.
In the case of POST data, the AOLserver automatically decodes the form data and stores the strings in an Ns_Set structure within the Ns_Conn structure for the current connection (the Ns_Set and Ns_Conn are described below). The set is accessible to your Tcl script through the ns_set
and ns_conn
functions.
Other content, such as PUT data, will be available to your operation function as a single block of memory in C that you may copy, modify, or save as you require. Within Tcl you can use the ns_writecontent
function to copy the content to a file on disk. Because everything in Tcl is a string, you cannot modify binary content directly. The ns_writecontent
function allows you to transfer the content to a disk file in a single operation without having to convert the data into a string format within your script.
By default operations are inherited. To register operations that are not inherited, you can set a flag when calling the C API function Ns_RegisterRequest() or add the -noinherit flag to the Tcl function ns_register_proc .