This is the reference documentation for Woof!, an open-source, platform and server-independent web application framework. For introductory material and a user guide, see the Woof! home page at http://woof.magicsplat.com.
Called by a webserver to handle a client request.
request_context | (optional, default ) opaque request context handle passed through to the web server module to identify this request. See request_init. |
Returns true if output has been sent to the client and false otherwise. Note that the output may be an error message but the command still returns true in that case. A new Response object is created and exported as response. This holds the response to be sent back to the client.
Called by a webserver to handle a client request.
The command obtains information about the request through callbacks implemented by the webserver interface module. The webserver module's request_init method is called to perform any per-request initialization or setup. A new Request object is created and exported as request. This contains information about the client request.
The request is then mapped to a particular controller and action by the url_crack command. The corresponding file is sourced into the ::woof::app namespace. Note that file is sourced only the first time it is required by a request and not for every request. Missing files are ignored under the premise that in that case only the template is to be rendered and no controller action is required.
The controller must be a descendent of the ApplicationController class. After loading and creating the controller object, it's process method is called which in turn invokes the action method in the controller.
Called by the master interpreter to initialize the safe web interpreter in which requests are processed.
Called by the master interpreter to initialize the safe web interpreter in which requests are processed.
Reads the routing configuration from disk.
Reads the routing configuration from disk.
Sources a file into the interpreter
path | path to the file to be sourced |
args | Additional options. |
-ignoremissing BOOLEAN | if true, then missing files are treated as though they exist but are empty. If false (default), an error is generated |
-sourceonce BOOLEAN | if true, then the file is not sourced if it has already been sourced. Default is false. This option is ignored if the configuration option reload_scripts is true. |
Sources a file into the interpreter
This is used only for sourcing application files, not for the core Woof! libraries.
path may be a relative path in which case it is assumed to be relative to the Woof root directory.
path must not be a volume-relative path as it does not interact properly with caching when the process' current directory on a drive is changed. There is never a need to use volume relative paths anyway.
path may also be an absolute path that includes a drive letter and the full path to the file to be sourced.
The path is verified to lie within the Woof directory structure. Note this is done even for relative paths since they make contain .. components.
Depending on the value of the reload_scripts configuration setting, the command will read the file from the Woof file cache.
The command remembers which files are passed in based on the path passed in as input, not on its normalized equivalent. Thus, a file may be sourced multiple times if each time it is accessed through a different syntactic path (e.g. relative) or through links. Note relative paths are always relative to the Woof root
Construct a URL for a controller and action
cracked_url | the dictionary as returned by url_crack |
args | Additional options. |
-action ACTION | name of the action. This defaults to index, and is not based on cracked_url |
-controller CONTROLLER | name of controller to use instead of the default from crack_url |
-fullyqualify BOOLEAN | if false (default), the constructed URL is relative to the URL in cracked_url, else the full path is included in the returned URL. |
-module MODULE | name of the module in which controller resides, if not the default from crack_url. This must be in the same format returned by url_crack. |
-parameters PARAMLIST | dictionary containing parameter and their values. These are encoded in the URL path if there is a matching route or as a query string otherwise. |
Returns a URL that will corresponds to the controller and action. Note this does not include server and port components.
Construct a URL for a controller and action
Construct application request context from a URL.
aurl | the URL of interest relative to the application URL root |
Returns a dictionary mapping the given relative URL path to a controller, action and related context.
Construct application request context from a URL.
If the URL matches a defined route, the corresponding controller and action are used.
If the specified URL does not match a route and is either empty or /, it defaults to the value of app_default_uri in the configuration file.
If no defined route was matched, the URL is parsed as follows: If the URL path has at least two components, the last is the action, the penultimate is the controller and any preceding path components comprise the module. If the URL has only one component, it is taken as the name of the controller, the action defaults to the value of app_default_action in the configuration file, and the module is empty.
The returned dictionary has the following keys:
action | the name of the action to be invoked |
app_dir | fully qualified name of the directory where the application code resides |
controller | the name of the controller referenced by the request |
controller_class | the name of the class (including module namespace qualifiers) corresponding to the controller |
controller_dir | the subdirectory within the application directory where the controller code resides |
controller_file | the name of the source file for the controller |
module | the name of the module referenced by the request as a list of module components (not in namespace format) |
original_app_url | the original url path below the application root supplied by client without any defaults or Woof! rewriting |
route_params | dictionary containing the parameters defined as part of the route |
search_dirs | list of directories to search for module-specific components such as stylesheets. Note the last element is always "." indicating the context-dependent root of the search tree. |
url_root | the root URL where the application resides |
Constructs a URL for a static file in the Woof tree
path | path to the file for which the URL is to be returned. |
default_url | (optional, default ) URL to be returned if the file is outside the public Woof area |
Returns the constructed URL.
Constructs a URL for a static file in the Woof tree
If path is relative, it is assumed to be relative to the Woof public directory.
If default_url is unspecified or is an empty string, an error is raised if the path is not public area.
Note the returned URL does not include the protocol, host or port.
Returns the version of Woof
Returns the version of Woof
Returns the version of Woof
action | Returns the name of the action specified in the current request. |
constructor | Constructor for the class |
include_image | Generates a HTML image tag |
include_javascript | Generates a javascript script link |
include_stylesheet | Generates a stylesheet link |
link_to | Generate a HTML link tag for a URL based on the given arguments |
process | Called to invoke a specific action in a controller. |
redirect | Redirects client to a different URL. |
render | Generates content for the web page. |
url_for | Constructs a URL based on the passed options and current request. |
url_for_image | Constructs the URL for a stylesheet |
url_for_javascript | Constructs the URL for a Javascript resource |
url_for_static | Constructs URL for a static resource such as an image. |
url_for_stylesheet | Constructs the URL for a stylesheet |
Base class for Woof controller classes.
request | the Request object encapsulating the client's request |
response | the Response object that will be used to hold the response to be sent to the client |
dispatchinfo | a dictionary containing the items returned by woof::url_crack for the request |
Base class for Woof controller classes.
This is the base class from which all application specific controller objects derive the standard functionality implemented by the process method. However, applications should derive controllers from the ApplicationController class and not directly from Controller. Any application-wide changes should be defined in that class and not by modifying this class.
Before invoking the controller action, an object session of class Session is created. This may correspond to an existing session or a new session if the request has missing or invalid session information. Application code can use this object to store persistent data.
Also before invoking the controller action, a Flash object is created containing context and data to be shared between consecutive requests. This can be accessed through the flash object.
A Page object page is created to track contents of the page and the list of languages specified in the Accept-Language HTTP header is passed to it.
The Map object pagevar is created to pass values related to page metadata such as stylesheets, scripts, page titles etc. Concrete controller classes may add to this.
Returns the name of the action specified in the current request.
Returns the name of the action specified in the current request.
Returns the name of the action specified in the current request.
Generates a HTML image tag
image | identifies the image, may be a file name, relative url or absolute (see url_for_static) |
args | may be either a variable number of alternating attribute and value elements or a single list argument containing them |
Generates a HTML image tag
Generates a javascript script link
js | identifies the stylesheet, may be a file name, relative url or absolute (see url_for_static) |
args | may be either a variable number of alternating attribute and value elements or a single list argument containing them |
Generates a javascript script link
Generates a stylesheet link
stylesheet | identifies the stylesheet, may be a file name, relative or absolute url (see url_for_static) |
args | may be either a variable number of alternating attribute and value elements or a single list argument containing them |
Generates a stylesheet link
Generate a HTML link tag for a URL based on the given arguments
html | the HTML text to display. Note this is the raw HTML and is not escaped by the command. |
args | may be either a variable number of option value pairs or a single argument containing the option value pairs. All options except -attrs are passed to url_for. |
-attrs ATTRLIST | list of attribute value pairs for the tag |
Generate a HTML link tag for a URL based on the given arguments
Called to invoke a specific action in a controller.
action | (optional, default ) the name of the action method to invoke. If specified as an empty string, the method name is picked from the URL of the request. |
Called to invoke a specific action in a controller.
By default, $action may refer to any exported method defined in the controller leaf class itself (i.e. not including inherited methods). A controller may define the method _action_methods to return a non-empty list of methods to restrict this. In this case, only those methods which are in the returned list are allowed to be invoked.
If the action method does not exist or is inaccessible, the method _missing_action is invoked and passed the action as an argument. The default implementation of this returns an error message to the user. A controller may override this to provide dynamic functionality.
The specific action is then invoked. If it has arguments, they are extracted from the query parameters in the array and passed as parameters to the action method.
After the action completes, if the page has not been rendered the render method is called to do so.
Finally, any changes to the session are committed before the command returns.
The session identifier for a new session, if created, is automatically stored in the cookies set in the client. Note this is only done when a new session is created. For existing sessions the cookie is already present on the client anyway.
Redirects client to a different URL.
args | Additional options. |
-action ACTION | specifies the action method for the URL |
-anchor ANCHOR | specifies the anchor to be included in the URL |
-controller CONTROLLER | specifies the controller for the URL |
-host HOST | specifies the host component |
-httpstatus HTTPSTATUSCODE | the HTTP response code to be sent to the client. |
-module MODULE | specifies the module in which the controller is defined |
-parameters PARAMLIST | dictionary specifying the query component |
-port PORT | specifies the port component |
-protocol PROTOCOL | specifies the protocol component |
-text STRING | the text to send as the response content. |
-url URL | specifies the redirection URL. Specifying this option will cause all other URL related options to be ignored. |
Redirects client to a different URL.
The arguments are constructed into a URL as described for the url_for method and the client is sent a HTTP redirect response directing it to the constructed URL.
This method and render are mutually exclusive. Both cannot be called during processing of a single request.
Generates content for the web page.
args | Additional options. |
-status HTTPSTATUS | sets the HTTP status for the response (default is 200) |
Generates content for the web page.
Generates html fragments for all page sections in a web page. The Page class object page holds the content for each page section. Refer to its documentation for more details.
It is an error to call this method more than once or after calling the redirect method.
Constructs a URL based on the passed options and current request.
args | may be either a variable number of option value pairs or a single argument containing the option value pairs |
-action ACTION | specifies the action method for the URL. If this option is not specified, but the -controller is, then this defaults to the application default action. |
-anchor ANCHOR | specifies the anchor to be included in the URL |
-controller CONTROLLER | specifies the controller for the URL |
-fullyqualify BOOLEAN | if true, a fully qualified URL (includes scheme and host) is returned in all cases. Default is false. If -host, -port or -protocol options are specified, it is always set to true. |
-host HOST | specifies the host component |
-module MODULE | specifies the module in which the controller is defined. Ignored unless controller is also specified. |
-parameters PARAMLIST | dictionary containing the parameters to be included in the URL path (see ::woof::url_build). |
-port PORT | specifies the port component |
-protocol PROTOCOL | specifies the protocol component |
-urlpath URLPATH | specifies the URL portion after the protocol and host components. Specifying this will cause all other URL related options to be ignored except -protocol, -host and -port. If URLPATH begins with '/', it is taken to be the entire URL after the host and port. Otherwise, it is assumed to be relative to the application's root URL. |
Constructs a URL based on the passed options and current request.
Constructs the URL for a stylesheet
image | identifies the image, may be a file name, relative or absolute url (see url_for_static) |
args | Additional options. |
Returns the constructed URL.
Constructs the URL for a stylesheet
args | may be either a variable number of alternating attribute and value elements or a single list argument containing them See url_for_static for options. |
Constructs the URL for a Javascript resource
js | identifies the Javascript resource, may be a file name, relative or absolute url (see url_for_static) |
args | Additional options. |
Returns the constructed URL.
Constructs the URL for a Javascript resource
args | may be either a variable number of alternating attribute and value elements or a single list argument containing them See url_for_static for options. |
Constructs URL for a static resource such as an image.
resource | name of resource, may be a file name or URL |
args | may be either a variable number of option value pairs or a single argument containing the option value pairs |
-fullyqualify BOOLEAN | if true, a fully qualified URL (includes scheme and host) is returned in all cases. |
-subdir RELATIVEDIR | subdirectory under the public directory that should be the root of the search. Only used if resource is a file. |
Returns the URL for the resource
Constructs URL for a static resource such as an image.
If resource contains any '/' characters, it is treated as a URL, else it is assumed to be the name of a file.
If the resource is a file, it is searched for in the search directory path for the controller. The root for all relative directories in the search path is the public directory under the Woof root unless the -subdir option is specified in which case that is used.
If the resource is a URL, it may be a a relative or an absolute URL. A relative URL is qualified with the URL root for the Woof application. An absolute URL is returned as is.
Constructs the URL for a stylesheet
stylesheet | identifies the stylesheet, may be a file name, relative or absolute url (see url_for_static) |
args | may be either a variable number of alternating attribute and value elements or a single list argument containing them See url_for_static for options. |
Returns the constructed URL.
Constructs the URL for a stylesheet
constructor | Constructor for the class |
lazy_load | Loads the cookie values on demand. |
clear | See util::Map.clear |
count | See util::Map.count |
exists | See util::Map.exists |
freeze | See util::Map.freeze |
get | See util::Map.get |
hget | See util::Map.hget |
init | See util::Map.init |
keys | See util::Map.keys |
lappend | See util::Map.lappend |
pop | See util::Map.pop |
set | See util::Map.set |
unset | See util::Map.unset |
util::Map | clear count exists freeze get hget init keys lappend pop set unset |
Provides an interface to contains cookies received as part of a request as a Map object.
raw_cookie |
Provides an interface to contains cookies received as part of a request as a Map object.
The cookies and corresponding values can be accessed using the standard Map methods.
Loads the cookie values on demand.
args | list of cookie keys |
Loads the cookie values on demand.
Note that for performance reasons, the method loads all cookie values in the Map and not justthe keys specified in args.
See Map.lazy_load for details of this call back method.
clear | Removes all cookies matching a pattern . |
constructor | Constructor for the class |
cookies | Returns a list of all cookies. Each element of the returned list is a cookie value, including attributes if any, that can be used as the value of a HTTP Set-Cookie header. |
count | Returns the number of defined cookies. |
exists | Check the existence of a cookie and optionally return its value. |
freeze | Makes the object read-only so no further updates to cookies are possible. |
get | Retrieves the value associated with a cookie |
keys | Returns a list of defined cookie names matching a pattern |
set | Sets the values of one or more cookies. |
setwithattr | Sets the value and attributes of a cookie |
unknown | Provides shorthand methods for setting and getting cookie values. |
unset | Removes a previously defined cookie. |
The CookiesOut class encapsulates cookies that are to be sent in the response to the client.
The CookiesOut class encapsulates cookies that are to be sent in the response to the client.
The class does not have Map as a base class but implements the same interface.
In addition to the associated value, cookies may have associated attributes as well which may be set with the setwithattr method.
Removes all cookies matching a pattern .
pattern | (optional, default *) pattern to match using the same syntax as the Tcl string match command. |
Removes all cookies matching a pattern .
Note this does not remove the cookies from the client side, only from the outgoing response.
Returns a list of all cookies. Each element of the returned list is a cookie value, including attributes if any, that can be used as the value of a HTTP Set-Cookie header.
Returns a list of all cookies. Each element of the returned list is a cookie value, including attributes if any, that can be used as the value of a HTTP Set-Cookie header.
Returns a list of all cookies. Each element of the returned list is a cookie value, including attributes if any, that can be used as the value of a HTTP Set-Cookie header.
Returns the number of defined cookies.
Returns the number of defined cookies.
Returns the number of defined cookies.
Check the existence of a cookie and optionally return its value.
cookie_name | cookie whose existence is to be checked |
v_val | (optional, default ) name of a variable in the caller's context |
Check the existence of a cookie and optionally return its value.
The method checks if the specified cookie exists in the object. The method returns false if the cookie does not exist. If the cookie exists, the method returns true and if v_val is specified, stores the value in the variable v_val in the caller's context.
Makes the object read-only so no further updates to cookies are possible.
Makes the object read-only so no further updates to cookies are possible.
Retrieves the value associated with a cookie
args | optional arguments |
Retrieves the value associated with a cookie
If the method is invoked with no parameters, the cookies are returned as a flat list of cookie name-value pairs.
If a single argument is specified, the method returns the associated value if the cookie exists. Otherwise an exception is generated.
If more than one argument is specified, the first argument is the cookie whose value is to be returned, and the second argument is the default value to be returned if the cookie does not exist.
Returns a list of defined cookie names matching a pattern
pattern | (optional, default *) pattern to match using the same syntax as the Tcl string match command. |
Returns a list of defined cookie names matching a pattern
Returns a list of defined cookie names matching a pattern
Sets the values of one or more cookies.
args | a list of key and value elements |
Sets the values of one or more cookies.
The value of each key specified is set to the corresponding specified value. No attributes are associated with the cookie.
Sets the value and attributes of a cookie
name | name of the cookie |
value | the value to associate with the cookie |
args | optional arguments to set attributes |
-deleteexisting BOOLEAN | normally values are appended to any previously set values for that cookie. If this option is specified as true, any previous values are removed. Note this refers to values being set in outgoing cookies on the the server, not the client side. |
-domain DOMAIN | sets the domain attribute which associates the cookie with a specific domain |
-expires EXPIRYTIME | sets the expiration for the cookie. If the option is not specified, the cookie expiration is 24 hours. If EXPIRYTIME is never, the cookie is set to never expire. A value of now expires the cookie immediately (in essence used to delete the cookie from the client). Otherwise, EXPIRYTIME must be a positive integer and interpreted as the number of seconds since 00:00:00 Jan 1, 1970. |
-httponly BOOLEAN | if true, includes the httponly attribute in the cookie |
-path PATH | sets the path attribute which associates the cookie with the specific URL path |
-secure BOOLEAN | if true, includes the secure attribute in the cookie |
Sets the value and attributes of a cookie
Provides shorthand methods for setting and getting cookie values.
args | The first parameter must be a cookie prefixed with a ":". The second optional parameter may be the value to associate with the key. |
Provides shorthand methods for setting and getting cookie values.
The following two methods are equivalent:
ocookies set humpty dumpty ocookies :humpty dumpty
Similarly, the following two are equivalent:
set cookie [ocookies get humpty] set cookie [ocookies :humpty]
Removes a previously defined cookie.
cookie_name | name of the cookie to be removed |
Removes a previously defined cookie.
Note this does not remove the cookie from the client side, only from the outgoing response.
constructor | Constructor for the class |
request | |
response | |
dispatchinfo | |
args | Additional options. |
constructor | Constructor for the class |
lazy_load | Loads the environment values on demand. |
clear | See util::Map.clear |
count | See util::Map.count |
exists | See util::Map.exists |
freeze | See util::Map.freeze |
get | See util::Map.get |
hget | See util::Map.hget |
init | See util::Map.init |
keys | See util::Map.keys |
lappend | See util::Map.lappend |
pop | See util::Map.pop |
set | See util::Map.set |
unset | See util::Map.unset |
util::Map | clear count exists freeze get hget init keys lappend pop set unset |
Constructs a Map object as provided by the web server.
request_context |
Constructs a Map object as provided by the web server.
Application code may access the environment using the standard Map interfaces.
Loads the environment values on demand.
args | See Map.lazy_load |
Loads the environment values on demand.
Note that for performance reasons, the method loads all environment values in the Map and not just the keys specified in args.
See Map.lazy_load for details.
constructor | Constructor for the class |
keep | Marks data that would be cleared as persistent until the next request. |
persistents | Get all persistent keys stored in the flash. |
transient | Stores data in the flash only for the current request. |
clear | See util::Map.clear |
count | See util::Map.count |
exists | See util::Map.exists |
freeze | See util::Map.freeze |
get | See util::Map.get |
hget | See util::Map.hget |
init | See util::Map.init |
keys | See util::Map.keys |
lappend | See util::Map.lappend |
lazy_load | See util::Map.lazy_load |
pop | See util::Map.pop |
set | See util::Map.set |
unset | See util::Map.unset |
util::Map | clear count exists freeze get hget init keys lappend lazy_load pop set unset |
Container for storage of temporary data that needs to be passed between actions, potentially across separate client requests.
args | Additional options. |
Container for storage of temporary data that needs to be passed between actions, potentially across separate client requests.
At times an application may need to pass data between actions (methods), either within the same request or across consecutive requests. This class is a Map with that added functionality.
Data stored in the flash in a request is made available in the next action (or request) and cleared thereafter. It may however be persisted further through the -keep method. Conversely, it's lifetime may be restricted to only the current request through the -transient method.
Marks data that would be cleared as persistent until the next request.
args | keys corresponding to the data to be persisted |
Marks data that would be cleared as persistent until the next request.
Normally, data in the flash is maintained until the request following the request that stored the data into the flash. When -keep is called, the data corresponding to the passed keys are persisted for the next request even if they would otherwise have been cleared in this request.
Get all persistent keys stored in the flash.
Returns all keys and values in the flash that will be maintained until the next request.
Get all persistent keys stored in the flash.
Stores data in the flash only for the current request.
args | list of key value pairs to store in the flash |
Stores data in the flash only for the current request.
Normally, data stored in the flash is maintained until the next request. However, data stored using -transient is cleared after the current request.
constructor | Constructor for the class |
request | |
response | |
dispatchinfo | |
args | Additional options. |
constructor | Constructor for the class |
content_type | Sets the content type of the page |
fetch | Check the existence of a page section and optionally return its content. |
store | Sets the content of the specified section. |
The Page object contains HTML content for page sections.
dispatchinfo | Dict containing request dispatch context as returned by url_split. |
args | Additional options. |
-languages LANGID_LIST | list of language identifiers in order of preference. See the fetch method for details. |
The Page object contains HTML content for page sections.
Objects of this class are intended to be used as containers to hold the HTML content of various sections in a page. Content for a section can be directly stored or retrieved using the store and fetch methods. If a particular section has not been defined when an attempt is made to retrieve it, the list of directories given by the search_dirs key in the passed dispatch context is searched for a subdirectory views containing a suitable template from which the section can be generated.
Sets the content type of the page
args | optional arguments |
Sets the content type of the page
If no arguments are specified, returns the current value of the page content-type. Otherwise, sets its value to the first argument and returns an empty string. Remaining arguments, if any, are currently ignored. If the first argument is the empty string, the Content-Type header is removed from the response.
The supplied value may contain a charset attribute as well.
Check the existence of a page section and optionally return its content.
section_name | name of page section |
varname | name of a variable in the caller's context |
args | Additional options. |
Check the existence of a page section and optionally return its content.
The method checks if the specified page section exists. It returns false if the section does not exist. If the section exists, the method returns true and stores the value in the variable of that name in the caller's context.
If the section has already been defined for the page, the method returns true and the section content is stored in varname if specified.
If the section has not been defined, the view search path, as passed through the search_dirs field in the dispatchinfo parameter in the constructor, is searched for a matching template for the controller and action.
If no languages were specified when the object was created, the search proceeds as follows: For the first directory in the view search path, the following file names are checked: CONTROLLER-ACTION-PAGESECTION.wtf, CONTROLLER-PAGESECTION.wtf, PAGESECTION.wtf. For the remaining directories in the search path, only PAGESECTION.wtf is checked. This is by design since it does not make sense for a file named after the controller and/or action to show further up (and hence outside) the controller content directory.
Note the filename is considered a more important matching criterion than the directory level.
If the -languages option was specified when the object was created, the above search is modified slightly. For each directory in the search path, subdirectories with the same name as the language identifiers specified in the option are first checked before the directory in the search path.
If a suitable template is found, the method returns true. If varname is specified, the template is rendered in the caller's context and the result is stored in varname and also as the content of the page section internally.
Sets the content of the specified section.
name | name of the section |
args | list of arguments to be concatenated. The resulting value is stored as the content of the page section. |
Sets the content of the specified section.
The content being stored is expected to be a properly formatted HTML fragment.
constructor | Constructor for the class |
lazy_load | Loads the query parameter values on demand. |
multiget | Returns multiple values for a query key |
clear | See util::Map.clear |
count | See util::Map.count |
exists | See util::Map.exists |
freeze | See util::Map.freeze |
get | See util::Map.get |
hget | See util::Map.hget |
init | See util::Map.init |
keys | See util::Map.keys |
lappend | See util::Map.lappend |
pop | See util::Map.pop |
set | See util::Map.set |
unset | See util::Map.unset |
util::Map | clear count exists freeze get hget init keys lappend pop set unset |
Contains the form and query string values associated with a request.
request_context |
Contains the form and query string values associated with a request.
Application code may access values associated with keys using the standard Map interfaces. The retrieved keys and values will have been fully decoded.
Loads the query parameter values on demand.
args | See Map.lazy_load |
Loads the query parameter values on demand.
Note that for performance reasons, the method loads all received parameter values in the Map and not just the keys specified in args. See Map.lazy_load for details.
Returns multiple values for a query key
key | key to look up |
Returns multiple values for a query key
A query or form may have multiple values associated with a given key. This method returns all these associated values for the specified key as a list. Note that even if the key has a single value, it is returned as a single-element list.
accept_languages | |
application_url | Returns the URL path where the application is rooted. |
constructor | Constructor for the class |
delete? | Returns true if the HTTP request method was a DELETE and false otherwise. |
formatted_host_with_port | Returns the host and port associated with this request. If the request came over the standard port for the protocol, it is not included in the returned string. |
get? | Returns true if the HTTP request method was a GET and false otherwise. |
get_or_head? | Returns true if the HTTP request method was a GET or HEAD and false otherwise. |
head? | Returns true if the HTTP request method was a HEAD and false otherwise. |
host | |
port | Returns the port on which the request was received. |
post? | Returns true if the HTTP request method was a POST and false otherwise. |
protocol | Returns the connection protocol over which the request was received. |
query_string | Returns the query string portion of request. |
referer | Returns the HTTP_REFERER header in the request if present, else an empty string |
remote_addr | Returns the address of the remote client if available, else an empty string. |
request_method | Returns the HTTP method in the request. |
request_uri | Returns the request URI (the portion after the hostname/port) for the request. |
resource_url | Returns the resource URL path within the application root URL. |
ssl? | Returns true if the request came over an SSL connection and false otherwise. |
standard_port | Returns the standard port used for the protocol over which the connection was received. |
url | Returns the full URL for the request |
A Request object holds various attributes and context associated with a received client request.
request_context | an opaque handle identifying the request that will be passed through to the web server module |
A Request object holds various attributes and context associated with a received client request.
A Request object is associated with every incoming request. Application code can use the methods of this object to retrieve various pieces of information about the received request.
This class contains default implementations of various methods to retrieve request information. A web server interface may specialize this to provide more efficient means of accessing data.
The environment passed by the web server is encapsulated as an Environment object may be accessed through the env method. Within application context in a Controller, this may also be accessed as the env object.
The cookies contained in the request may be accessed as a CookiesIn object through the 'cookies' method. Again, within application context in a Controller object, this can also be accessed as the icookies object.
The query and form string values received with the request may be accessed as a Params object through the params method. Within application context in a Controller, it can also be accessed as the params object.
Returns the URL path where the application is rooted.
Returns the URL path where the application is rooted.
Note the returned path does not include the protocol, host or port number.
Returns true if the HTTP request method was a DELETE and false otherwise.
Returns true if the HTTP request method was a DELETE and false otherwise.
Returns true if the HTTP request method was a DELETE and false otherwise.
Returns the host and port associated with this request. If the request came over the standard port for the protocol, it is not included in the returned string.
Returns the host and port associated with this request. If the request came over the standard port for the protocol, it is not included in the returned string.
Returns the host and port associated with this request. If the request came over the standard port for the protocol, it is not included in the returned string.
Returns true if the HTTP request method was a GET and false otherwise.
Returns true if the HTTP request method was a GET and false otherwise.
Returns true if the HTTP request method was a GET and false otherwise.
Returns true if the HTTP request method was a GET or HEAD and false otherwise.
Returns true if the HTTP request method was a GET or HEAD and false otherwise.
Returns true if the HTTP request method was a GET or HEAD and false otherwise.
Returns true if the HTTP request method was a HEAD and false otherwise.
Returns true if the HTTP request method was a HEAD and false otherwise.
Returns true if the HTTP request method was a HEAD and false otherwise.
Returns the port on which the request was received.
Returns the port on which the request was received.
Returns the port on which the request was received.
Returns true if the HTTP request method was a POST and false otherwise.
Returns true if the HTTP request method was a POST and false otherwise.
Returns true if the HTTP request method was a POST and false otherwise.
Returns the connection protocol over which the request was received.
Returns the connection protocol over which the request was received.
Returns the connection protocol over which the request was received.
Returns the query string portion of request.
Returns the query string portion of request.
Note that the returned query string is not in decoded form. Use the Params object instead to retrieve decoded values.
Returns the HTTP_REFERER header in the request if present, else an empty string
Returns the HTTP_REFERER header in the request if present, else an empty string
Returns the HTTP_REFERER header in the request if present, else an empty string
Returns the address of the remote client if available, else an empty string.
Returns the address of the remote client if available, else an empty string.
Returns the address of the remote client if available, else an empty string.
Returns the HTTP method in the request.
Returns the HTTP method in the request.
Returns the HTTP method in the request.
Returns the request URI (the portion after the hostname/port) for the request.
Returns the request URI (the portion after the hostname/port) for the request.
Returns the request URI (the portion after the hostname/port) for the request.
Returns the resource URL path within the application root URL.
Returns the resource URL path within the application root URL.
This is the portion of the request url beyond the application root url and excludes the query string.
Returns true if the request came over an SSL connection and false otherwise.
Returns true if the request came over an SSL connection and false otherwise.
Returns true if the request came over an SSL connection and false otherwise.
Returns the standard port used for the protocol over which the connection was received.
Returns the standard port used for the protocol over which the connection was received.
Note this is not necessarily the same as the port on which the request actually arrived.
Returns the full URL for the request
Returns the full URL for the request
Returns the full URL for the request
charset | Set or retrieves the charset attribute sent with the Content-Type header in the HTTP response. |
constructor | Constructor for the class |
content | Sets or returns the content for the HTTP response |
content_type | Sets or returns the Content-Type header of the HTTP response. |
cookies | Invokes the CookiesOut object containing the cookies to be sent to the client. |
headers | Retrieves or sets the HTTP headers defined in the object. |
last_modified | Sets or returns the Last-Modified header of the HTTP response. |
location | Sets or returns the Location header to be sent in the HTTP response. |
redirect | Sets the response to be a HTTP redirect |
reset | Currently not implemented. |
status | Sets or returns the HTTP response status code to be sent to the client. |
status_line | Returns the HTTP response status line to be sent to the client. |
Constructs an object for returning data to the client.
Constructs an object for returning data to the client.
An object of this class, named response, is created in the context of every Controller object that handles a request from the client. The application code should use this object to construct the response to be sent back to the client including HTTP headers, content, cookies etc.. The object is then used by the installed web server interface to communicate with the web server to send the appropriate response to the client.
Set or retrieves the charset attribute sent with the Content-Type header in the HTTP response.
args | optional arguments. |
Set or retrieves the charset attribute sent with the Content-Type header in the HTTP response.
If no arguments are specified, returns the current setting of the charset attribute. Otherwise, sets the charset attribute of the Content-Type header to the first argument and return an empty string. If the first argument is the empty string, the charset attribute is removed from the header. Remaining arguments, if any, are currently ignored.
Sets or returns the content for the HTTP response
args | optional arguments that specify the content. |
Sets or returns the content for the HTTP response
If no arguments are specified, returns the current content stored in the response. If one or more arguments are specified, they are concatenated together and stored as the response content and an empty string returned.
Sets or returns the Content-Type header of the HTTP response.
args | optional arguments |
Returns the value of the Content-Type header without the charset attribute.
Sets or returns the Content-Type header of the HTTP response.
If no arguments are specified, returns the current value of the Content-Type header. Otherwise, sets its value to the first argument and returns an empty string. Remaining arguments, if any, are currently ignored. If the first argument is the empty string, the Content-Type header is removed from the response.
The supplied value may contain a charset attribute as well. If it does not, the current charset attribute of the header is preserved.
Invokes the CookiesOut object containing the cookies to be sent to the client.
args | all arguments are passed on to the wrapped CookiesOut object. |
Invokes the CookiesOut object containing the cookies to be sent to the client.
This method wraps the CookiesOut object that contains the cookies to be sent to the client. When called without any arguments, invokes the get method of the CookiesOut object. When called with arguments, invokes the object using those arguments.
The same CookiesOut object is also made available to application code as the ocookies object. Generally, applications should directly invoke that object instead of calling this method.
Retrieves or sets the HTTP headers defined in the object.
args | arguments to be passed to the wrapped Map object containing HTTP headers to be sent to the client. |
Retrieves or sets the HTTP headers defined in the object.
The response object contains a Map object with the HTTP headers to be sent to the client. This method wraps that object and passes on args to that object. If invoked without any arguments, returns a list of the HTTP headers that will be sent from this Response object as a flat list of header name and header value pairs. This list will include the response cookies. Note that the list can contain multiple pairs that have the same header name.
Generally, application code should not call this method to set header values directly. Instead it should call the other methods of the Response object, such as location, content_type, charset and last_modified that will then set the headers appropriately.
On the other hand, web server interface code can call this method to retrieve the set of headers to send back to the client.
Caller should treat the return value as a dictionary as headers can be repeated (for example the Set-Cookie header).
Sets or returns the Last-Modified header of the HTTP response.
utc | (optional, default ) timestamp |
Sets or returns the Last-Modified header of the HTTP response.
If no arguments are specified, returns the current value of the Last-Modified header if one has been defined, and an empty string otherwise.
If utc is specified and not empty, the Last-Modified header is set to its value and an empty string is returned. utc must be either in the standard HTTP date and time format, or an integer which is then treated as the number of seconds since 00:00:00 Jan 1 1970 UTC. An error is thrown if the format is neither of these two.
Sets or returns the Location header to be sent in the HTTP response.
loc | (optional, default ) The value of the location header to be sent. |
Sets or returns the Location header to be sent in the HTTP response.
If loc is specified and not empty, the value of the HTTP Location header is set to loc and the empty string is returned. Otherwise, returns the location header set in the response or an empty string if no Location header has been set.
Sets the response to be a HTTP redirect
url | the URL to which client is to be redirected |
status | (optional, default 307) the HTTP response code to be sent to the client |
text | (optional, default ) The HTML content to sent as part of the HTTP response. Note this is HTML content and is not HTML-escaped further. |
Sets the response to be a HTTP redirect
Currently not implemented.
Currently not implemented.
Sets or returns the HTTP response status code to be sent to the client.
status | (optional, default ) HTTP integer response code |
Sets or returns the HTTP response status code to be sent to the client.
If $status is specified and is not the empty string, sets the HTTP response status code for this object and returns an empty string. Otherwise, returns the currently set HTTP response status code.
Returns the HTTP response status line to be sent to the client.
Returns the full HTTP response line.
Returns the HTTP response status line to be sent to the client.
commit | Commits the session content to persistent storage. |
constructor | Constructor for the class |
id | Returns the session id for this session. |
id_name | Returns the name of the key used for the session id |
load | Loads session data from session storage |
new? | Indicates if this session was created in this request |
clean | See util::DirtyMap.clean |
clear | See util::DirtyMap.clear |
count | See util::Map.count |
dirty | See util::DirtyMap.dirty |
dirty? | See util::DirtyMap.dirty? |
exists | See util::Map.exists |
freeze | See util::Map.freeze |
get | See util::Map.get |
hget | See util::Map.hget |
init | See util::DirtyMap.init |
keys | See util::Map.keys |
lappend | See util::DirtyMap.lappend |
lazy_load | See util::Map.lazy_load |
pop | See util::Map.pop |
set | See util::DirtyMap.set |
unset | See util::DirtyMap.unset |
util::DirtyMap | clean clear dirty dirty? init lappend set unset |
util::Map | count exists freeze get hget keys lazy_load pop |
Container for persistent session data.
id | (optional, default ) the session id for the session. |
args | Additional options. |
-id_name SESSION_ID_NAME | specifies SESSION_ID_NAME to be used as the name of the field containing the session id. By default the name session_id is used. |
Container for persistent session data.
A session is a container for data that is to be persisted across web requests. It is identified by a session id that is generally stored on the client side (e.g. as a cookie) and passed in every request to associate the request with a particular session. When a request comes in, Woof! creates a session object which may correspond to a new session or contain content of an existing session to which the request has been mapped. Application code may access and store items in this session using the standard Map interfaces.
If the parameter $id is an empty string, a new session is created. If parameter $id is not an empty string, the session content for the corresponding session is restored from persistent storage. An error is generated if no corresponding session data is found.
Commits the session content to persistent storage.
force | (optional, default false) |
Returns the session id for the session.
Commits the session content to persistent storage.
The session may be restored by creating a new Session object using the returned session id.
Returns the session id for this session.
Returns the session id for this session.
Returns the session id for this session.
Returns the name of the key used for the session id
Returns the name of the key used for the session id
Returns the name of the key used for the session id
Loads session data from session storage
Loads session data from session storage
Indicates if this session was created in this request
Returns true if the session is a new one created in this request. If the session was an existing one created in a previous request, returns false.
Indicates if this session was created in this request
Finds and loads a controller class
name | name of the controller class, optionally namespace qualified |
Finds and loads a controller class
The command locates and loads the specified controller class if it has not already been loaded in ::woof::app namespace.
The command must be called from the top level when a source is being sourced as the file from which the class is being loaded is dependent on the script from where it is called.
The class name name may be unqualified in which case, it is located in the same directory as the caller and loaded into the caller's namespace.
If name is a qualified name it must be relative to the ::woof::app namespace (not fully qualified) and include the entire path under it.
The corresponding file is then loaded into that namespace, and not the namespace of the caller since by convention controller files are defined without namespaces and are expected to be loaded into the appropriate namespace by the caller.
Raises a Tcl exception in Woof canonical format.
facility | the error facility, generally WOOF or WOOF_USER |
symbol | the symbolic name of the error |
message | (optional, default ) the error message. If none is supplied, the default message for the error symbol is used. |
Raises a Tcl exception in Woof canonical format.
The exception is raised from the caller's context with an error code consisting of the facility, error symbol and the message.
Returns the help message, if any, associated with the given facility and symbol.
facility | the error facility, generally WOOF or WOOF_USER |
symbol | the symbolic name of the error |
Returns the help message, if any, associated with the given facility and symbol.
Returns the help message, if any, associated with the given facility and symbol.
Returns the HTML for a Pure CSS styled button
text | text to display in the button. This is HTML-escaped before display. |
args | Additional options. |
-classes CSSCLASSES | additional CSS classes to style the button. |
-enabled BOOLEAN | controls whether button is enabled (default) or not |
-onclick JAVASCRIPT | Javascript to execute when the button is clicked |
-pressed BOOLEAN | controls whether button is shown as pressed or not. Default is 0. |
-primary BOOLEAN | style as a primary button (default false) |
-type button|submit|reset | specifies the type of the button. |
Returns the HTML for a Pure CSS styled button
Returns the HTML for a Pure CSS styled button
-url | URL to link to |
Returns a PureCSS styled form
formdef | form definition list as described below |
args | Additional options. |
-layout inline|stacked|aligned | Specifies the form layout which may be aligned (labels next to entry fields), stacked (labels above entry fields) or inline (all fields on the same line, default) |
-title TEXT | a legend to use for the form |
Returns a PureCSS styled form
The input form element creates a label and an associated text entry field. The second element of the pair is a dictionary with the following keys and corresponding values. Keys that are optional are indicated as such.
-enabled | a boolean value (optional, default 1) that marks the field as enabled or not |
-id | Specifies the id attribute of the input field (optional) |
-label | the text to use for the text entry label (optional) |
-name | the name of the text entry field for the form |
-placeholder | Directly translates to the placeholder attribute in the generated HTML (optional) |
-readonly | a boolean value (optional, default 0) that specifies that the entry cannot be edited |
-required | a boolean value (optional, default 0) that specifies whether the form submission requires the field to be filled |
-rounded | a boolean value (optional, default 0) that specifies that the input field borders be rounded |
-type | Specifies the type of the input field. Directly passed through as the type attribute in the generated HTML. |
-value | Initial value to display for the field (optional) |
Returns a Pure CSS styled image.
url | URL for the image |
alt | (optional, default Image) |
Returns a Pure CSS styled image.
Pure CSS styles images are automatically adjusted for the width of the containing section.
Returns the HTML for a Pure CSS styled menu
menudefs | list of menu definitions |
args | Additional options. |
-classes CLASSES | list of additional CSS classes to add to the menu |
-heading TEXT | text to display as the heading for the menu |
-orient DIRECTION | specifies orientation of the menu. By default, it is displayed horizontally. See below for possible other values. |
-state open|closed | specifies whether to display the menu as open (default) or closed |
Returns the HTML for a Pure CSS styled menu
If the target URL is empty, the menu item is shown disabled.
selected | the menu item is shown selected |
Returns HTML for a Pure CSS formatted paginator
range | list of one or two integers denoting the range of page numbers. If the second number is omitted, there is no upper limit. |
url_prefix | the prefix of the URL to use for each page. The page number is appended to this when constructing the URL for each button. |
args | Additional options. |
-active NUMBER | the page number that is currently active |
-count COUNT | Number of page buttons |
-start START | First page number to show |
Returns HTML for a Pure CSS formatted paginator
Returns HTML for a Pure CSS formatted paginator
Returns the HTML for a Pure CSS styled table
data | list of sublists with each sublist corresponding to a table row |
args | Additional options. |
-borders vertical|horizontal|both | specifies which cell borders are drawn. By default only the vertical borders are drawn. |
-heading HEADER | specifies the table heading. |
-raw BOOLEAN | if true, heading and cell contents are not HTML-escaped. Default is false. |
-stripes BOOLEAN | if true, alternate table rows are shaded. Default is false. |
Returns the HTML for a Pure CSS styled table
Returns the HTML for a Pure CSS styled table
Returns a URL constructed from specified controller, action and parameters
routes | |
curl | URL fragment for the controller |
action | name of the action |
args | Additional options. |
-parameters PARAMLIST | dictionary containing parameter values |
Returns a URL constructed from specified controller, action and parameters
The first route matching the above conditions is used to construct a relative URL. If any parameters from PARAMLIST were left over, they are included as query parameters.
Parses the specified routes file
route_definitions | string containing route definitions |
Returns a set of routes the structure of should be treated as opaque.
Parses the specified routes file
The string is evaluated as a Tcl script in a safe interpreter. It may include any Tcl code and in addition the following commands that set up the dispatch routes.
curl CURL ACTIONS PURL
The command curl defines a controller route.
CURL | controller URL path (relative URL) |
ACTIONS | list of actions included in this definition |
PURL | URL for parameter definitions |
The command creates a definition mapping a (relative) URL to a controller.
CURL specifies the URL for the controller and may include a module path. The last component of CURL is the controller name and any prior components specify the module
ACTIONS specifies the action methods for which the definition is applicable. This may be a list of action names, an empty list which indicates the definition applies to all actions, or a string beginning with 'implicit:'. In this last case, the URL is treated as not having an action component and any remaining components after the controller are matched against parameter definitions. The string after the 'implicit:' prefix is treated as the action method to invoke.
PURL is a URL path that defines additional parameters that are supplied in the rest of the URL. Note these are not the explicit parameters sent as part of a query or form post but rather additional parameters that may be merged with them. Each component in this PURL should have the format
PARAMNAME:REGEXP:DEFAULT
where PARAMNAME specifies the name of the parameter, REGEXP, if not empty, specifies a regular expression that the URL component should match, and DEFAULT is the default value to be used if the URL component is missing. DEFAULT is actually passed through the Tcl subst command with -nocommands options hence variable definitions and backslash sequences can be used.
In addition, PARAMNAME field of the last path component in PURL may be of the form
*NAME
in which case the corresponding parameter is a list of all remaining URL component values.
Note that the ':' character in the default value should be encoded using \u Tcl escape sequences else it will be treated as the start of the default value as opposed to be embedded in it.
The returned route structures can be passed to select and construct to map URL's to controller actions and vice-versa.
Reads a file containing route definitions.
rpath | path to the file |
Reads a file containing route definitions.
Reads the content of the specified file and parses it using parse_routes.
See parse_routes for format of the routing definitions.
Matches the specified URL against the list of route definitions
routes | list of routes as returned by parse_routes |
rurl | relative URL, without query or fragment components |
args | Additional options. |
-defaultaction ACTION | action name if none specified in URL (default is index) |
Matches the specified URL against the list of route definitions
It is expected that rurl is in normalized and decoded form.
iana_cs | |
default_cs | (optional, default ) |
tcl_cs | |
default_cs | (optional, default ) |
Checks if the specified path is a descendent of the specified directory
path | path to check |
dirpath | directory path under which path is expected to lie |
Checks if the specified path is a descendent of the specified directory
Returns the value for a key from a dictionary and a default if the key is not present
dict | the dictionary |
key | the key to retrieve. Nested keys are not supported |
default_value | default value to return if key is not present |
Returns the value for a key from a dictionary and a default if the key is not present
Returns the value for a key from a dictionary and a default if the key is not present
Removes and returns the value for a key from a dictionary and a default if the key is not present.
vdict | the name of the variable containing the dictionary |
key | the key to retrieve. Nested keys are not supported |
default_value | default value to return if key is not present |
Removes and returns the value for a key from a dictionary and a default if the key is not present.
Exports all procs in *caller's* namespace that do not begin with an underscore
Exports all procs in *caller's* namespace that do not begin with an underscore
Format a date and time as required by HTTP
secs | seconds since 00:00:00 Jan 1 1970 as returned by the [clock seconds] command |
Returns the corresponding HTTP formatted date.
Format a date and time as required by HTTP
Returns a new generated name
prefix | (optional, default ::woof::id_) a prefix to be used for the name |
Returns a new generated name
Returns a new generated name
Generate a session identifier.
Returns a string that is suitable to be used as a session identifier.
Generate a session identifier.
WARNING: this command currently does not return a session identifier that is cryptographically secure.
str |
Maps HTTP response codes to a HTTP response strings
code | the response code to map |
Returns the corresponding HTTP response string.
Maps HTTP response codes to a HTTP response strings
Select a content attribute for a HTTP response
header_value | the HTTP Accept-* value (excluding the Accept-* header) |
available | list of available attribute values |
default_value | value to return if there is no match |
Select a content attribute for a HTTP response
The command matches the requested HTTP header value against what is available and returns the matched value. The HTTP header value is in the format used for the Accept, Accept-Charset or Accept-Language headers.
Parses a multi-valued HTTP header string and returns the values sorted by their quality attribute
header_value | the HTTP header value such as those for the Accept-* headers. Should not include the header itself. |
Parses a multi-valued HTTP header string and returns the values sorted by their quality attribute
The command sorts the values specified in the header and returns them sorted by their associated quality attributes. For example, the value "text/html;q=0.2, text/xml, application/pdf ;q=0.3" will be result in "text/xml application/pdf text/html" being returned.
Generates HTML for a list based navigation tree
linkdefs | a list of link definitions. |
selection | the selected link, if any, from linkdefs |
args | Additional options. |
-hrefcmd COMMANDPREFIX | if specified, COMMANDPREFIX is executed with an argument specifying the link reference and should return the URL to use for the link. |
Generates HTML for a list based navigation tree
linkdefs is a list of triples, the first element in each triple being the link reference, the second being the raw HTML text to be displayed, and the optional third element being the nesting level. The link references are assumed to be unique.
The returned HTML is a hierarchical unnumbered list. Each item is an HTML link except for the one corresponding to selection. An item from linkdefs is included if it matches one of the following criteria:
The returned HTML is not styled in any fashion. It is up to the caller to appropriately use stylesheets for layout and appearance.
Constructs a URL query string from the given arguments
args | list of alternating keys and values. If a single argument is given, it is itself treated as such a list |
Constructs a URL query string from the given arguments
If no arguments are specified, returns an empty string, otherwise returns a query string prefixed with ? and suitably escaped for inclusion into a URL.
Construct a URL path relative to a base URL
base | the base URL |
target | the URL for which a path relative to base is to be constructed |
Construct a URL path relative to a base URL
Evaluates and caches a command result
args | command and arguments to evaluate |
Evaluates and caches a command result
If args was previously evaluated, its result is returned from the cache. Otherwise, it is evaluated in the caller's context and the result is stored in the cache before being returned.
Note that calls from different contexts will be treated as identical if args are syntatically identical.
Converts an identifier containing underscores into mixed case
name | identifier to be converted |
Returns the converted identifier.
Converts an identifier containing underscores into mixed case
The return value is constructed by removing all non-leading and non-trailing underscore characters and changing the following letter to upper case. This is the reciprocal of the unmixcase proc.
Splits a string into a list based on the specified criteria
s | string to be split |
sep | character that separates the fields in the string. This must not be the same as the quoting characters. |
quote_chars | (optional, default \") a list of one or two characters that specify the start and end character for quoted substrings. If the list has only one element, the start and end quotes are the same. |
esc | (optional, default \) the character used to escape other characters within the quoted string. |
transform | (optional, default ) command prefix to invoke on each field before adding it to the returned list. Used for trimming whitespace, for example. |
Splits a string into a list based on the specified criteria
Removes the left margin from the lines in the specified text
text | text string |
args | Additional options. |
-combineempties BOOLEAN | if true, multiple blank lines are combined into one. Default is false. |
-returnlist BOOLEAN | if true, the command returns a list of lines. If false (default), the command returns a string with the lines are joined with newlines. |
-skipleadingempties BOOLEAN | if true, leading blank lines are skipped. Default is false. |
Removes the left margin from the lines in the specified text
The command trims leading whitespace from all lines in text.
The very first non empty line determines the margin. This will be removed from all subsequent lines. Note that this assumes that if tabs are used for indentation, they are used on all lines in consistent fashion.
Converts a HTTP formatted date to seconds since the epoch
datestr | a date time string formatted as per the HTTP specification |
Returns the date and time as the number of seconds since 0:0:0 Jan 1, 1970.
Converts a HTTP formatted date to seconds since the epoch
args | Additional options. |
Converts an mixed case identifier to a lower case one with underscores
name | identifier to be converted |
Returns the converted identifier.
Converts an mixed case identifier to a lower case one with underscores
The return value is constructed by replacing upper case characters by lower case ones, preceded by an underscore character. This is the reciprocal of the mixcase proc.
Decode a www-url-encoded string
str | the string to be converted |
Returns the decoded string.
Decode a www-url-encoded string
Encode a string in www-url-encoded format
str | string to be encoded |
Returns the encoded string.
Encode a string in www-url-encoded format
clean | Marks the object as being unmodified. |
clear | Calls Map::clear with all arguments and marks the object dirty. |
constructor | Constructor for the class |
dirty | Marks the object as being modified. |
dirty? | Returns true if the object has been modified since it was constructed and false otherwise |
init | Calls Map::init with all arguments and marks the object dirty. |
lappend | Calls Map::lappend with all arguments and marks the object dirty. |
set | Calls Map::set with all arguments and marks the object dirty. |
unset | Calls Map::unset with all arguments and marks the object dirty. |
count | See Map.count |
exists | See Map.exists |
freeze | See Map.freeze |
get | See Map.get |
hget | See Map.hget |
keys | See Map.keys |
lazy_load | See Map.lazy_load |
pop | See Map.pop |
Map | count exists freeze get hget keys lazy_load pop |
Constructs a Map with the additional functionality that state is maintained about whether the contents have been modified.
args | Additional options. |
Constructs a Map with the additional functionality that state is maintained about whether the contents have been modified.
Marks the object as being unmodified.
Marks the object as being unmodified.
Calls Map::clear with all arguments and marks the object dirty.
args | passed on to Map::clear |
Calls Map::clear with all arguments and marks the object dirty.
Marks the object as being modified.
Marks the object as being modified.
Returns true if the object has been modified since it was constructed and false otherwise
Returns true if the object has been modified since it was constructed and false otherwise
Returns true if the object has been modified since it was constructed and false otherwise
Calls Map::init with all arguments and marks the object dirty.
args | passed on to Map::init |
Calls Map::init with all arguments and marks the object dirty.
Calls Map::lappend with all arguments and marks the object dirty.
key | passed on to Map::lappend |
args | passed on to Map::lappend |
Calls Map::lappend with all arguments and marks the object dirty.
Calls Map::set with all arguments and marks the object dirty.
args | passed on to Map::set |
Calls Map::set with all arguments and marks the object dirty.
Calls Map::unset with all arguments and marks the object dirty.
args | passed on to Map::set |
Calls Map::unset with all arguments and marks the object dirty.
clear | Removes all keys matching the specified pattern from the object. |
constructor | Constructor for the class |
count | Returns the number of keys in the object. |
exists | Check the existence of a key and optionally return its value. |
freeze | Makes the object read-only. |
get | Retrieves values associated with keys. |
hget | Retrieves the value of a key in HTML encoded form. |
init | Initialize uninitialized keys. |
keys | Returns the list of keys contained in the object. |
lappend | Appends given arguments to the list value for the specified key |
lazy_load | Abstract method to fill in missing values for keys. |
pop | Retrieves the value associated with a key and removes the key from the object. |
set | Sets the values of one or more keys in the object. |
unset | Removes one or more keys from the object. |
DirtyMap, ::woof::CookiesIn, ::woof::Environment, ::woof::Params, ::woof::Flash
Constructs a dictionary-like object with additional functionality.
map | (optional, default ) is a list of key value pairs that will be used to initialize the list |
Constructs a dictionary-like object with additional functionality.
In addition to the defined methods, the object also creates dynamic methods based on the key names stored in the object. The value associated with any key can be retrieved or set by invoking a method whose name is the key prefixed with a ':' character.
The class also provides some support for acting as a cache for data stored in a backend. A derived class can redefine the lazy_load method to retrieve (but not set) key values on demand from some arbitrary source.
Removes all keys matching the specified pattern from the object.
pattern | (optional, default *) the pattern to match |
Removes all keys matching the specified pattern from the object.
The keys are matched againt pattern using the matching rules of the Tcl string match command.
Returns the number of keys in the object.
Returns the number of keys in the object.
Returns the number of keys in the object.
Check the existence of a key and optionally return its value.
key | key whose existence is to be checked |
v_val | (optional, default ) name of a variable in the caller's context |
Check the existence of a key and optionally return its value.
The method checks if the specified key exists in the object. The method returns false if the key does not exist. If the key exists, the method returns true and if v_val is specified, stores the value in the variable v_val in the caller's context.
Makes the object read-only.
Makes the object read-only.
After freeze is invoked, the object cannot be modified and any call to a method that would modify the object will raise an exception instead.
Retrieves values associated with keys.
args | optional arguments |
Retrieves values associated with keys.
If the method is invoked with no parameters, the content of the object is returned as a flat list of key value pairs.
Otherwise, the first argument is treated as the key and if it exists in the object, its value is returned.
If the key does not currently exist in the object, the method lazy_load is called to attempt to retrieve it and if successful the value is returned.
If still unsuccessful and exactly two arguments are specified, the second argument is treated as the default value and returned. Otherwise, an error is generated.
Retrieves the value of a key in HTML encoded form.
key | key whose associated value is to be retrieved |
Retrieves the value of a key in HTML encoded form.
An exception is generated if the key does not exist in the object.
Initialize uninitialized keys.
args | a possibly empty list of alternating key value elements. If a single argument is specified, it must itself be such a list. |
Initialize uninitialized keys.
The value of each key specified is set to the corresponding specified value if the key did not already exist in the object.
Returns the list of keys contained in the object.
Returns the list of keys contained in the object.
Note this does NOT return keys that are present in the back end (if any) but not in this object. Caller may explicitly call lazy_load before calling this method if that is desired.
Appends given arguments to the list value for the specified key
key | |
args | values to append to the entry |
Appends given arguments to the list value for the specified key
Abstract method to fill in missing values for keys.
args | keys whose values are to be filled in. |
Abstract method to fill in missing values for keys.
This method is called when an attempt is made to retrieve the values for keys that are not present. This method is a no-op but may be overridden by a derived class to return a value for the key. The derived class can call the set method to set the value for the key. It may also set the values for more than one key.
If args is empty, all missing keys should be filled in, where the term all is up to the derived class.
Retrieves the value associated with a key and removes the key from the object.
key | key whose associated value is to be returned. |
defval | (optional, default ) default value to be returned if the key does not exist in the object. |
Retrieves the value associated with a key and removes the key from the object.
Sets the values of one or more keys in the object.
args | a list of key value elements. If a single argument is specified, it must itself be such a list. |
Sets the values of one or more keys in the object.
The value of each key specified is set to the corresponding specified value.
Removes one or more keys from the object.
args | list of keys to be removed |
Removes one or more keys from the object.
in |
in | |
var | (optional, default OUT) |
content | |
args | Additional options. |
The first element is the name of the variable that will contain generated output. Second element is the string to execute in caller's context. The variable might have been used before so empty it first.
ct |
The first element is the name of the variable that will contain generated output. Second element is the string to execute in caller's context. The variable might have been used before so empty it first.
ct |
in | |
var | (optional, default OUT) |
data | |
ncols | (optional, default 2) |
args | Additional options. |