NaviServer - programmable web server
4.99  5.0

[ Main Table Of Contents | Table Of Contents | Keyword Index ]

ns_urlspace(n) 4.99.30 naviserver "NaviServer Built-in Commands"

Name

ns_urlspace - Assign Application Data to URLs.

Table Of Contents

Synopsis

Description

The command ns_urlspace allows one to assign/query/list/delete data to the trie representing the URL space. The command supports filters and inheritance such one can e.g. assign data to certain patterns of pages (e.g. to .adp-pages) or such one can assign data to a higher level node which can be inherited to all nodes below this one.

The values assigned to the URL space are shared among all threads of a server. So this command is somewhat similar to the set of nsv commands, but differs in its inheritance and filtering capabilities.

The command allows e.g. to implement access control (like the nsperm module) on the Tcl level. Other applications are e.g. blacklisting of certain parts of the URL tree from statistics, or to assign different master templates to different parts of the URL tree.

COMMANDS

ns_urlspace set ?-id id? ?-key key? ?-noinherit? url value

Assign a value to a node in the URL space. Per default, the value is inherited to all sub-nodes, unless the option -noinherit is specified.

ns_urlspace get ?-id id? ?-key key? ?-exact? ?-noinherit? url value

Retrieve a value from the URL space for a specified URL. Per default, the returned values might be inherited from a parent node. When the option -exact is used, the inheritance is deactivated, and only the values are returned directly assigned to the URL. When the option -noinherit is specified, only values set with the -noinherit flag are returned.

ns_urlspace list ?-id id?

List the values assigned to the URL space. The command returns a list of lists, containing for every item the 5 elements

  • key

  • path

  • filter pattern

  • the constants inherit or noinherit

  • the assigned data

ns_urlspace unset ?-id id? ?-key key? ?-noinherit? ?-recurse? url

Unset a value for a URL for the given or default key. This command undoes the effects of ns_urlspace set. When the options -noinherit is used the values set this way are deleted and vice versa. The option -recurse performs the operation recursively. Unless -recurse is specified, the command returns 1 or 0 on success or failure.

ns_urlspace new

Allocate a new URL space id. When the number of compile-time configured URL spaces runs out, a Tcl exception is raised.

OPTIONS

-id id

ID of the URL space. In general, multiple different URL spaces could be used, which can be allocated with the command ns_urlspace new. The maximum number of available URL spaces is a compile time constant of NaviServer. When no ID is specified, NaviServer allocates automatically a default ID on first usage.

-key key

Every URL has a key assigned, which is logically part of the URL space. Using this key, one could for example use the HTTP methods GET or POST to assign different values to a URL for GET or POST requests. The key can be used as well for other purposes. If no key is specified, it default to the constant "." (dot character).

See Also

nsv

Keywords

data structure, server built-in, shared, trie, urlspace, variables