Introduction

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.

::woof

Commands

handle_request [::woof]

woof, Top

Called by a webserver to handle a client request.

handle_request request_context

Parameters
request_context(optional, default ) opaque request context handle passed through to the web server module to identify this request. See request_init.
Return value

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.

Description

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.

init [::woof]

woof, Top

Called by the master interpreter to initialize the safe web interpreter in which requests are processed.

init

Description

Called by the master interpreter to initialize the safe web interpreter in which requests are processed.

read_routes [::woof]

woof, Top

Reads the routing configuration from disk.

read_routes

Description

Reads the routing configuration from disk.

source_file [::woof]

woof, Top

Sources a file into the interpreter

source_file path args

Parameters
path path to the file to be sourced
argsAdditional 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.
Description

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

url_build [::woof]

woof, Top

Construct a URL for a controller and action

url_build cracked_url args

Parameters
cracked_url the dictionary as returned by url_crack
argsAdditional 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.
Return value

Returns a URL that will corresponds to the controller and action. Note this does not include server and port components.

Description

Construct a URL for a controller and action

url_crack [::woof]

woof, Top

Construct application request context from a URL.

url_crack aurl

Parameters
aurl the URL of interest relative to the application URL root
Return value

Returns a dictionary mapping the given relative URL path to a controller, action and related context.

Description

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

url_for_file [::woof]

woof, Top

Constructs a URL for a static file in the Woof tree

url_for_file path default_url

Parameters
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
Return value

Returns the constructed URL.

Description

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.

version [::woof]

woof, Top

Returns the version of Woof

version

Return value

Returns the version of Woof

Description

Returns the version of Woof

Classes

Controller [::woof]

woof, Top

actionReturns the name of the action specified in the current request.
constructorConstructor for the class
include_imageGenerates a HTML image tag
include_javascriptGenerates a javascript script link
include_stylesheetGenerates a stylesheet link
link_toGenerate a HTML link tag for a URL based on the given arguments
processCalled to invoke a specific action in a controller.
redirectRedirects client to a different URL.
renderGenerates content for the web page.
url_forConstructs a URL based on the passed options and current request.
url_for_imageConstructs the URL for a stylesheet
url_for_javascriptConstructs the URL for a Javascript resource
url_for_staticConstructs URL for a static resource such as an image.
url_for_stylesheetConstructs the URL for a stylesheet
constructor [::woof::Controller]

Controller, Top

Base class for Woof controller classes.

::woof::Controller create request response dispatchinfo

Parameters
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
Description

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.

action [::woof::Controller]

Controller, Top

Returns the name of the action specified in the current request.

OBJECT action

Return value

Returns the name of the action specified in the current request.

Description

Returns the name of the action specified in the current request.

include_image [::woof::Controller]

Controller, Top

Generates a HTML image tag

OBJECT include_image image args

Parameters
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
Description

Generates a HTML image tag

include_javascript [::woof::Controller]

Controller, Top

Generates a javascript script link

OBJECT include_javascript js args

Parameters
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
Description

Generates a javascript script link

include_stylesheet [::woof::Controller]

Controller, Top

Generates a stylesheet link

OBJECT include_stylesheet stylesheet args

Parameters
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
Description

Generates a stylesheet link

link_to [::woof::Controller]

Controller, Top

Generate a HTML link tag for a URL based on the given arguments

OBJECT link_to html args

Parameters
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
Description

Generate a HTML link tag for a URL based on the given arguments

process [::woof::Controller]

Controller, Top

Called to invoke a specific action in a controller.

OBJECT process action

Parameters
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.
Description

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.

redirect [::woof::Controller]

Controller, Top

Redirects client to a different URL.

OBJECT redirect args

Parameters
argsAdditional 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.
Description

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.

render [::woof::Controller]

Controller, Top

Generates content for the web page.

OBJECT render args

Parameters
argsAdditional options.
-status HTTPSTATUS sets the HTTP status for the response (default is 200)
Description

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.

url_for [::woof::Controller]

Controller, Top

Constructs a URL based on the passed options and current request.

OBJECT url_for args

Parameters
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.
Description

Constructs a URL based on the passed options and current request.

url_for_image [::woof::Controller]

Controller, Top

Constructs the URL for a stylesheet

OBJECT url_for_image image args

Parameters
image identifies the image, may be a file name, relative or absolute url (see url_for_static)
argsAdditional options.
Return value

Returns the constructed URL.

Description

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.
url_for_javascript [::woof::Controller]

Controller, Top

Constructs the URL for a Javascript resource

OBJECT url_for_javascript js args

Parameters
js identifies the Javascript resource, may be a file name, relative or absolute url (see url_for_static)
argsAdditional options.
Return value

Returns the constructed URL.

Description

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.
url_for_static [::woof::Controller]

Controller, Top

Constructs URL for a static resource such as an image.

OBJECT url_for_static resource args

Parameters
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.
Return value

Returns the URL for the resource

Description

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.

url_for_stylesheet [::woof::Controller]

Controller, Top

Constructs the URL for a stylesheet

OBJECT url_for_stylesheet stylesheet args

Parameters
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.
Return value

Returns the constructed URL.

Description

Constructs the URL for a stylesheet

CookiesIn [::woof]

woof, Top

constructorConstructor for the class
lazy_loadLoads the cookie values on demand.
clearSee util::Map.clear
countSee util::Map.count
existsSee util::Map.exists
freezeSee util::Map.freeze
getSee util::Map.get
hgetSee util::Map.hget
initSee util::Map.init
keysSee util::Map.keys
lappendSee util::Map.lappend
popSee util::Map.pop
setSee util::Map.set
unsetSee util::Map.unset
Superclasses

util::Map

Inherited and mixed-in methods
util::Mapclear count exists freeze get hget init keys lappend pop set unset
constructor [::woof::CookiesIn]

CookiesIn, Top

Provides an interface to contains cookies received as part of a request as a Map object.

::woof::CookiesIn create raw_cookie

Parameters
raw_cookie
Description

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.

lazy_load [::woof::CookiesIn]

CookiesIn, Top

Loads the cookie values on demand.

OBJECT lazy_load args

Parameters
args list of cookie keys
Description

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.

CookiesOut [::woof]

woof, Top

clearRemoves all cookies matching a pattern .
constructorConstructor for the class
cookiesReturns 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.
countReturns the number of defined cookies.
existsCheck the existence of a cookie and optionally return its value.
freezeMakes the object read-only so no further updates to cookies are possible.
getRetrieves the value associated with a cookie
keysReturns a list of defined cookie names matching a pattern
setSets the values of one or more cookies.
setwithattrSets the value and attributes of a cookie
unknownProvides shorthand methods for setting and getting cookie values.
unsetRemoves a previously defined cookie.
constructor [::woof::CookiesOut]

CookiesOut, Top

The CookiesOut class encapsulates cookies that are to be sent in the response to the client.

::woof::CookiesOut create

Description

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.

clear [::woof::CookiesOut]

CookiesOut, Top

Removes all cookies matching a pattern .

OBJECT clear pattern

Parameters
pattern(optional, default *) pattern to match using the same syntax as the Tcl string match command.
Description

Removes all cookies matching a pattern .

Note this does not remove the cookies from the client side, only from the outgoing response.

cookies [::woof::CookiesOut]

CookiesOut, Top

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.

OBJECT cookies

Return value

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.

Description

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 [::woof::CookiesOut]

CookiesOut, Top

Returns the number of defined cookies.

OBJECT count

Return value

Returns the number of defined cookies.

Description

Returns the number of defined cookies.

exists [::woof::CookiesOut]

CookiesOut, Top

Check the existence of a cookie and optionally return its value.

OBJECT exists cookie_name v_val

Parameters
cookie_name cookie whose existence is to be checked
v_val(optional, default ) name of a variable in the caller's context
Description

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.

freeze [::woof::CookiesOut]

CookiesOut, Top

Makes the object read-only so no further updates to cookies are possible.

OBJECT freeze

Description

Makes the object read-only so no further updates to cookies are possible.

get [::woof::CookiesOut]

CookiesOut, Top

Retrieves the value associated with a cookie

OBJECT get args

Parameters
args optional arguments
Description

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.

keys [::woof::CookiesOut]

CookiesOut, Top

Returns a list of defined cookie names matching a pattern

OBJECT keys pattern

Parameters
pattern(optional, default *) pattern to match using the same syntax as the Tcl string match command.
Return value

Returns a list of defined cookie names matching a pattern

Description

Returns a list of defined cookie names matching a pattern

set [::woof::CookiesOut]

CookiesOut, Top

Sets the values of one or more cookies.

OBJECT set args

Parameters
args a list of key and value elements
Description

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.

setwithattr [::woof::CookiesOut]

CookiesOut, Top

Sets the value and attributes of a cookie

OBJECT setwithattr name value args

Parameters
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
Description

Sets the value and attributes of a cookie

unknown [::woof::CookiesOut]

CookiesOut, Top

Provides shorthand methods for setting and getting cookie values.

OBJECT unknown args

Parameters
args The first parameter must be a cookie prefixed with a ":". The second optional parameter may be the value to associate with the key.
Description

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]
unset [::woof::CookiesOut]

CookiesOut, Top

Removes a previously defined cookie.

OBJECT unset cookie_name

Parameters
cookie_name name of the cookie to be removed
Description

Removes a previously defined cookie.

Note this does not remove the cookie from the client side, only from the outgoing response.

DevModeOnly [::woof]

woof, Top

constructorConstructor for the class
constructor [::woof::DevModeOnly]

DevModeOnly, Top

::woof::DevModeOnly create request response dispatchinfo args

Parameters
request
response
dispatchinfo
argsAdditional options.

Environment [::woof]

woof, Top

constructorConstructor for the class
lazy_loadLoads the environment values on demand.
clearSee util::Map.clear
countSee util::Map.count
existsSee util::Map.exists
freezeSee util::Map.freeze
getSee util::Map.get
hgetSee util::Map.hget
initSee util::Map.init
keysSee util::Map.keys
lappendSee util::Map.lappend
popSee util::Map.pop
setSee util::Map.set
unsetSee util::Map.unset
Superclasses

util::Map

Inherited and mixed-in methods
util::Mapclear count exists freeze get hget init keys lappend pop set unset
constructor [::woof::Environment]

Environment, Top

Constructs a Map object as provided by the web server.

::woof::Environment create request_context

Parameters
request_context
Description

Constructs a Map object as provided by the web server.

Application code may access the environment using the standard Map interfaces.

lazy_load [::woof::Environment]

Environment, Top

Loads the environment values on demand.

OBJECT lazy_load args

Parameters
args See Map.lazy_load
Description

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.

Flash [::woof]

woof, Top

constructorConstructor for the class
keepMarks data that would be cleared as persistent until the next request.
persistentsGet all persistent keys stored in the flash.
transientStores data in the flash only for the current request.
clearSee util::Map.clear
countSee util::Map.count
existsSee util::Map.exists
freezeSee util::Map.freeze
getSee util::Map.get
hgetSee util::Map.hget
initSee util::Map.init
keysSee util::Map.keys
lappendSee util::Map.lappend
lazy_loadSee util::Map.lazy_load
popSee util::Map.pop
setSee util::Map.set
unsetSee util::Map.unset
Superclasses

util::Map

Inherited and mixed-in methods
util::Mapclear count exists freeze get hget init keys lappend lazy_load pop set unset
constructor [::woof::Flash]

Flash, Top

Container for storage of temporary data that needs to be passed between actions, potentially across separate client requests.

::woof::Flash create args

Parameters
argsAdditional options.
Description

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.

keep [::woof::Flash]

Flash, Top

Marks data that would be cleared as persistent until the next request.

OBJECT keep args

Parameters
args keys corresponding to the data to be persisted
Description

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.

persistents [::woof::Flash]

Flash, Top

Get all persistent keys stored in the flash.

OBJECT persistents

Return value

Returns all keys and values in the flash that will be maintained until the next request.

Description

Get all persistent keys stored in the flash.

transient [::woof::Flash]

Flash, Top

Stores data in the flash only for the current request.

OBJECT transient args

Parameters
args list of key value pairs to store in the flash
Description

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.

LocalClientOnly [::woof]

woof, Top

constructorConstructor for the class
constructor [::woof::LocalClientOnly]

LocalClientOnly, Top

::woof::LocalClientOnly create request response dispatchinfo args

Parameters
request
response
dispatchinfo
argsAdditional options.

Page [::woof]

woof, Top

constructorConstructor for the class
content_typeSets the content type of the page
fetchCheck the existence of a page section and optionally return its content.
storeSets the content of the specified section.
constructor [::woof::Page]

Page, Top

The Page object contains HTML content for page sections.

::woof::Page create dispatchinfo args

Parameters
dispatchinfo Dict containing request dispatch context as returned by url_split.
argsAdditional options.
-languages LANGID_LIST list of language identifiers in order of preference. See the fetch method for details.
Description

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.

content_type [::woof::Page]

Page, Top

Sets the content type of the page

OBJECT content_type args

Parameters
args optional arguments
Description

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.

fetch [::woof::Page]

Page, Top

Check the existence of a page section and optionally return its content.

OBJECT fetch section_name varname args

Parameters
section_name name of page section
varname name of a variable in the caller's context
argsAdditional options.
Description

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.

store [::woof::Page]

Page, Top

Sets the content of the specified section.

OBJECT store name args

Parameters
name name of the section
args list of arguments to be concatenated. The resulting value is stored as the content of the page section.
Description

Sets the content of the specified section.

The content being stored is expected to be a properly formatted HTML fragment.

Params [::woof]

woof, Top

constructorConstructor for the class
lazy_loadLoads the query parameter values on demand.
multigetReturns multiple values for a query key
clearSee util::Map.clear
countSee util::Map.count
existsSee util::Map.exists
freezeSee util::Map.freeze
getSee util::Map.get
hgetSee util::Map.hget
initSee util::Map.init
keysSee util::Map.keys
lappendSee util::Map.lappend
popSee util::Map.pop
setSee util::Map.set
unsetSee util::Map.unset
Superclasses

util::Map

Inherited and mixed-in methods
util::Mapclear count exists freeze get hget init keys lappend pop set unset
constructor [::woof::Params]

Params, Top

Contains the form and query string values associated with a request.

::woof::Params create request_context

Parameters
request_context
Description

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.

lazy_load [::woof::Params]

Params, Top

Loads the query parameter values on demand.

OBJECT lazy_load args

Parameters
args See Map.lazy_load
Description

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.

multiget [::woof::Params]

Params, Top

Returns multiple values for a query key

OBJECT multiget key

Parameters
key key to look up
Return value

Returns multiple values for a query key

Description

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.

Request [::woof]

woof, Top

accept_languages
application_urlReturns the URL path where the application is rooted.
constructorConstructor for the class
delete?Returns true if the HTTP request method was a DELETE and false otherwise.
formatted_host_with_portReturns 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
portReturns the port on which the request was received.
post?Returns true if the HTTP request method was a POST and false otherwise.
protocolReturns the connection protocol over which the request was received.
query_stringReturns the query string portion of request.
refererReturns the HTTP_REFERER header in the request if present, else an empty string
remote_addrReturns the address of the remote client if available, else an empty string.
request_methodReturns the HTTP method in the request.
request_uriReturns the request URI (the portion after the hostname/port) for the request.
resource_urlReturns the resource URL path within the application root URL.
ssl?Returns true if the request came over an SSL connection and false otherwise.
standard_portReturns the standard port used for the protocol over which the connection was received.
urlReturns the full URL for the request
constructor [::woof::Request]

Request, Top

A Request object holds various attributes and context associated with a received client request.

::woof::Request create request_context

Parameters
request_context an opaque handle identifying the request that will be passed through to the web server module
Description

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.

accept_languages [::woof::Request]

Request, Top

OBJECT accept_languages

application_url [::woof::Request]

Request, Top

Returns the URL path where the application is rooted.

OBJECT application_url

Return value

Returns the URL path where the application is rooted.

Description

Note the returned path does not include the protocol, host or port number.

delete? [::woof::Request]

Request, Top

Returns true if the HTTP request method was a DELETE and false otherwise.

OBJECT delete?

Return value

Returns true if the HTTP request method was a DELETE and false otherwise.

Description

Returns true if the HTTP request method was a DELETE and false otherwise.

formatted_host_with_port [::woof::Request]

Request, Top

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.

OBJECT formatted_host_with_port

Return value

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.

Description

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? [::woof::Request]

Request, Top

Returns true if the HTTP request method was a GET and false otherwise.

OBJECT get?

Return value

Returns true if the HTTP request method was a GET and false otherwise.

Description

Returns true if the HTTP request method was a GET and false otherwise.

get_or_head? [::woof::Request]

Request, Top

Returns true if the HTTP request method was a GET or HEAD and false otherwise.

OBJECT get_or_head?

Return value

Returns true if the HTTP request method was a GET or HEAD and false otherwise.

Description

Returns true if the HTTP request method was a GET or HEAD and false otherwise.

head? [::woof::Request]

Request, Top

Returns true if the HTTP request method was a HEAD and false otherwise.

OBJECT head?

Return value

Returns true if the HTTP request method was a HEAD and false otherwise.

Description

Returns true if the HTTP request method was a HEAD and false otherwise.

host [::woof::Request]

Request, Top

OBJECT host

port [::woof::Request]

Request, Top

Returns the port on which the request was received.

OBJECT port

Return value

Returns the port on which the request was received.

Description

Returns the port on which the request was received.

post? [::woof::Request]

Request, Top

Returns true if the HTTP request method was a POST and false otherwise.

OBJECT post?

Return value

Returns true if the HTTP request method was a POST and false otherwise.

Description

Returns true if the HTTP request method was a POST and false otherwise.

protocol [::woof::Request]

Request, Top

Returns the connection protocol over which the request was received.

OBJECT protocol

Return value

Returns the connection protocol over which the request was received.

Description

Returns the connection protocol over which the request was received.

query_string [::woof::Request]

Request, Top

Returns the query string portion of request.

OBJECT query_string

Return value

Returns the query string portion of request.

Description

Note that the returned query string is not in decoded form. Use the Params object instead to retrieve decoded values.

referer [::woof::Request]

Request, Top

Returns the HTTP_REFERER header in the request if present, else an empty string

OBJECT referer

Return value

Returns the HTTP_REFERER header in the request if present, else an empty string

Description

Returns the HTTP_REFERER header in the request if present, else an empty string

remote_addr [::woof::Request]

Request, Top

Returns the address of the remote client if available, else an empty string.

OBJECT remote_addr

Return value

Returns the address of the remote client if available, else an empty string.

Description

Returns the address of the remote client if available, else an empty string.

request_method [::woof::Request]

Request, Top

Returns the HTTP method in the request.

OBJECT request_method

Return value

Returns the HTTP method in the request.

Description

Returns the HTTP method in the request.

request_uri [::woof::Request]

Request, Top

Returns the request URI (the portion after the hostname/port) for the request.

OBJECT request_uri

Return value

Returns the request URI (the portion after the hostname/port) for the request.

Description

Returns the request URI (the portion after the hostname/port) for the request.

resource_url [::woof::Request]

Request, Top

Returns the resource URL path within the application root URL.

OBJECT resource_url

Return value

Returns the resource URL path within the application root URL.

Description

This is the portion of the request url beyond the application root url and excludes the query string.

ssl? [::woof::Request]

Request, Top

Returns true if the request came over an SSL connection and false otherwise.

OBJECT ssl?

Return value

Returns true if the request came over an SSL connection and false otherwise.

Description

Returns true if the request came over an SSL connection and false otherwise.

standard_port [::woof::Request]

Request, Top

Returns the standard port used for the protocol over which the connection was received.

OBJECT standard_port

Return value

Returns the standard port used for the protocol over which the connection was received.

Description

Note this is not necessarily the same as the port on which the request actually arrived.

url [::woof::Request]

Request, Top

Returns the full URL for the request

OBJECT url

Return value

Returns the full URL for the request

Description

Returns the full URL for the request

Response [::woof]

woof, Top

charsetSet or retrieves the charset attribute sent with the Content-Type header in the HTTP response.
constructorConstructor for the class
contentSets or returns the content for the HTTP response
content_typeSets or returns the Content-Type header of the HTTP response.
cookiesInvokes the CookiesOut object containing the cookies to be sent to the client.
headersRetrieves or sets the HTTP headers defined in the object.
last_modifiedSets or returns the Last-Modified header of the HTTP response.
locationSets or returns the Location header to be sent in the HTTP response.
redirectSets the response to be a HTTP redirect
resetCurrently not implemented.
statusSets or returns the HTTP response status code to be sent to the client.
status_lineReturns the HTTP response status line to be sent to the client.
constructor [::woof::Response]

Response, Top

Constructs an object for returning data to the client.

::woof::Response create

Description

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.

charset [::woof::Response]

Response, Top

Set or retrieves the charset attribute sent with the Content-Type header in the HTTP response.

OBJECT charset args

Parameters
args optional arguments.
Description

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.

content [::woof::Response]

Response, Top

Sets or returns the content for the HTTP response

OBJECT content args

Parameters
args optional arguments that specify the content.
Description

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.

content_type [::woof::Response]

Response, Top

Sets or returns the Content-Type header of the HTTP response.

OBJECT content_type args

Parameters
args optional arguments
Return value

Returns the value of the Content-Type header without the charset attribute.

Description

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.

cookies [::woof::Response]

Response, Top

Invokes the CookiesOut object containing the cookies to be sent to the client.

OBJECT cookies args

Parameters
args all arguments are passed on to the wrapped CookiesOut object.
Description

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.

headers [::woof::Response]

Response, Top

Retrieves or sets the HTTP headers defined in the object.

OBJECT headers args

Parameters
args arguments to be passed to the wrapped Map object containing HTTP headers to be sent to the client.
Description

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).

last_modified [::woof::Response]

Response, Top

Sets or returns the Last-Modified header of the HTTP response.

OBJECT last_modified utc

Parameters
utc(optional, default ) timestamp
Description

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.

location [::woof::Response]

Response, Top

Sets or returns the Location header to be sent in the HTTP response.

OBJECT location loc

Parameters
loc(optional, default ) The value of the location header to be sent.
Description

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.

redirect [::woof::Response]

Response, Top

Sets the response to be a HTTP redirect

OBJECT redirect url status text

Parameters
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.
Description

Sets the response to be a HTTP redirect

reset [::woof::Response]

Response, Top

Currently not implemented.

OBJECT reset

Description

Currently not implemented.

status [::woof::Response]

Response, Top

Sets or returns the HTTP response status code to be sent to the client.

OBJECT status status

Parameters
status(optional, default ) HTTP integer response code
Description

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.

status_line [::woof::Response]

Response, Top

Returns the HTTP response status line to be sent to the client.

OBJECT status_line

Return value

Returns the full HTTP response line.

Description

Returns the HTTP response status line to be sent to the client.

Session [::woof]

woof, Top

commitCommits the session content to persistent storage.
constructorConstructor for the class
idReturns the session id for this session.
id_nameReturns the name of the key used for the session id
loadLoads session data from session storage
new?Indicates if this session was created in this request
cleanSee util::DirtyMap.clean
clearSee util::DirtyMap.clear
countSee util::Map.count
dirtySee util::DirtyMap.dirty
dirty?See util::DirtyMap.dirty?
existsSee util::Map.exists
freezeSee util::Map.freeze
getSee util::Map.get
hgetSee util::Map.hget
initSee util::DirtyMap.init
keysSee util::Map.keys
lappendSee util::DirtyMap.lappend
lazy_loadSee util::Map.lazy_load
popSee util::Map.pop
setSee util::DirtyMap.set
unsetSee util::DirtyMap.unset
Superclasses

util::DirtyMap

Inherited and mixed-in methods
util::DirtyMapclean clear dirty dirty? init lappend set unset
util::Mapcount exists freeze get hget keys lazy_load pop
constructor [::woof::Session]

Session, Top

Container for persistent session data.

::woof::Session create id args

Parameters
id(optional, default ) the session id for the session.
argsAdditional 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.
Description

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.

commit [::woof::Session]

Session, Top

Commits the session content to persistent storage.

OBJECT commit force

Parameters
force(optional, default false)
Return value

Returns the session id for the session.

Description

Commits the session content to persistent storage.

The session may be restored by creating a new Session object using the returned session id.

id [::woof::Session]

Session, Top

Returns the session id for this session.

OBJECT id

Return value

Returns the session id for this session.

Description

Returns the session id for this session.

id_name [::woof::Session]

Session, Top

Returns the name of the key used for the session id

OBJECT id_name

Return value

Returns the name of the key used for the session id

Description

Returns the name of the key used for the session id

load [::woof::Session]

Session, Top

Loads session data from session storage

OBJECT load

Description

Loads session data from session storage

new? [::woof::Session]

Session, Top

Indicates if this session was created in this request

OBJECT new?

Return value

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.

Description

Indicates if this session was created in this request

::woof::app

Commands

uses [::woof::app]

app, Top

Finds and loads a controller class

uses name

Parameters
name name of the controller class, optionally namespace qualified
Description

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.

::woof::errors

Commands

exception [::woof::errors]

errors, Top

Raises a Tcl exception in Woof canonical format.

exception facility symbol message

Parameters
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.
Description

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.

help [::woof::errors]

errors, Top

Returns the help message, if any, associated with the given facility and symbol.

help facility symbol

Parameters
facility the error facility, generally WOOF or WOOF_USER
symbol the symbolic name of the error
Return value

Returns the help message, if any, associated with the given facility and symbol.

Description

Returns the help message, if any, associated with the given facility and symbol.

::woof::pure

Commands

button [::woof::pure]

pure, Top

Returns the HTML for a Pure CSS styled button

button text args

Parameters
text text to display in the button. This is HTML-escaped before display.
argsAdditional 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.
Return value

Returns the HTML for a Pure CSS styled button

Description

Returns the HTML for a Pure CSS styled button

-url URL to link to

form [::woof::pure]

pure, Top

Returns a PureCSS styled form

form formdef args

Parameters
formdef form definition list as described below
argsAdditional 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
Return value

Returns a PureCSS styled form

Description

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)

img [::woof::pure]

pure, Top

Returns a Pure CSS styled image.

img url alt

Parameters
url URL for the image
alt(optional, default Image)
Return value

Returns a Pure CSS styled image.

Description

Pure CSS styles images are automatically adjusted for the width of the containing section.

menu [::woof::pure]

pure, Top

Returns the HTML for a Pure CSS styled menu

menu menudefs args

Parameters
menudefs list of menu definitions
argsAdditional 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
Return value

Returns the HTML for a Pure CSS styled menu

Description

If the target URL is empty, the menu item is shown disabled.

selected the menu item is shown selected

paginator [::woof::pure]

pure, Top

Returns HTML for a Pure CSS formatted paginator

paginator range url_prefix args

Parameters
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.
argsAdditional options.
-active NUMBER the page number that is currently active
-count COUNT Number of page buttons
-start START First page number to show
Return value

Returns HTML for a Pure CSS formatted paginator

Description

Returns HTML for a Pure CSS formatted paginator

table [::woof::pure]

pure, Top

Returns the HTML for a Pure CSS styled table

table data args

Parameters
data list of sublists with each sublist corresponding to a table row
argsAdditional 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.
Return value

Returns the HTML for a Pure CSS styled table

Description

Returns the HTML for a Pure CSS styled table

::woof::route

Commands

construct [::woof::route]

route, Top

Returns a URL constructed from specified controller, action and parameters

construct routes curl action args

Parameters
routes
curl URL fragment for the controller
action name of the action
argsAdditional options.
-parameters PARAMLIST dictionary containing parameter values
Return value

Returns a URL constructed from specified controller, action and parameters

Description

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.

parse_routes [::woof::route]

route, Top

Parses the specified routes file

parse_routes route_definitions

Parameters
route_definitions string containing route definitions
Return value

Returns a set of routes the structure of should be treated as opaque.

Description

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.

read_routes [::woof::route]

route, Top

Reads a file containing route definitions.

read_routes rpath

Parameters
rpath path to the file
Description

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.

select [::woof::route]

route, Top

Matches the specified URL against the list of route definitions

select routes rurl args

Parameters
routes list of routes as returned by parse_routes
rurl relative URL, without query or fragment components
argsAdditional options.
-defaultaction ACTION action name if none specified in URL (default is index)
Description

Matches the specified URL against the list of route definitions

It is expected that rurl is in normalized and decoded form.

::woof::route::test

Commands

init [::woof::route::test]

test, Top

init

::woof::util

Commands

charset_iana2tcl [::woof::util]

util, Top

charset_iana2tcl iana_cs default_cs

Parameters
iana_cs
default_cs(optional, default )

charset_tcl2iana [::woof::util]

util, Top

charset_tcl2iana tcl_cs default_cs

Parameters
tcl_cs
default_cs(optional, default )

contained_path [::woof::util]

util, Top

Checks if the specified path is a descendent of the specified directory

contained_path path dirpath

Parameters
path path to check
dirpath directory path under which path is expected to lie
Description

Checks if the specified path is a descendent of the specified directory

dict_get [::woof::util]

util, Top

Returns the value for a key from a dictionary and a default if the key is not present

dict_get dict key default_value

Parameters
dict the dictionary
key the key to retrieve. Nested keys are not supported
default_value default value to return if key is not present
Return value

Returns the value for a key from a dictionary and a default if the key is not present

Description

Returns the value for a key from a dictionary and a default if the key is not present

dict_pop [::woof::util]

util, Top

Removes and returns the value for a key from a dictionary and a default if the key is not present.

dict_pop vdict key default_value

Parameters
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
Description

Removes and returns the value for a key from a dictionary and a default if the key is not present.

export_all [::woof::util]

util, Top

Exports all procs in *caller's* namespace that do not begin with an underscore

export_all

Description

Exports all procs in *caller's* namespace that do not begin with an underscore

format_http_date [::woof::util]

util, Top

Format a date and time as required by HTTP

format_http_date secs

Parameters
secs seconds since 00:00:00 Jan 1 1970 as returned by the [clock seconds] command
Return value

Returns the corresponding HTTP formatted date.

Description

Format a date and time as required by HTTP

generate_name [::woof::util]

util, Top

Returns a new generated name

generate_name prefix

Parameters
prefix(optional, default ::woof::id_) a prefix to be used for the name
Return value

Returns a new generated name

Description

Returns a new generated name

generate_session_id [::woof::util]

util, Top

Generate a session identifier.

generate_session_id

Return value

Returns a string that is suitable to be used as a session identifier.

Description

Generate a session identifier.

WARNING: this command currently does not return a session identifier that is cryptographically secure.

hesc [::woof::util]

util, Top

hesc str

Parameters
str

http_response_code [::woof::util]

util, Top

Maps HTTP response codes to a HTTP response strings

http_response_code code

Parameters
code the response code to map
Return value

Returns the corresponding HTTP response string.

Description

Maps HTTP response codes to a HTTP response strings

http_select_header_value [::woof::util]

util, Top

Select a content attribute for a HTTP response

http_select_header_value header_value available default_value

Parameters
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
Description

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.

http_sorted_header_values [::woof::util]

util, Top

Parses a multi-valued HTTP header string and returns the values sorted by their quality attribute

http_sorted_header_values header_value

Parameters
header_value the HTTP header value such as those for the Accept-* headers. Should not include the header itself.
Description

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.

make_navigation_links [::woof::util]

util, Top

Generates HTML for a list based navigation tree

make_navigation_links linkdefs selection args

Parameters
linkdefs a list of link definitions.
selection the selected link, if any, from linkdefs
argsAdditional 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.
Description

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:

  • it is a top level item
  • it is the selected item itself or an ancestor
  • it shares part of the selected items ancestral path. Intuitively, this means the item can be reached from the selection by going upward and sideways without any downward steps.
  • it is a child (not any descendent) of the selected item
  • it is a sibling of the selected item

The returned HTML is not styled in any fashion. It is up to the caller to appropriately use stylesheets for layout and appearance.

make_query_string [::woof::util]

util, Top

Constructs a URL query string from the given arguments

make_query_string args

Parameters
args list of alternating keys and values. If a single argument is given, it is itself treated as such a list
Description

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.

make_relative_url [::woof::util]

util, Top

Construct a URL path relative to a base URL

make_relative_url base target

Parameters
base the base URL
target the URL for which a path relative to base is to be constructed
Description

Construct a URL path relative to a base URL

memoize [::woof::util]

util, Top

Evaluates and caches a command result

memoize args

Parameters
args command and arguments to evaluate
Description

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.

mixcase [::woof::util]

util, Top

Converts an identifier containing underscores into mixed case

mixcase name

Parameters
name identifier to be converted
Return value

Returns the converted identifier.

Description

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.

quoted_split [::woof::util]

util, Top

Splits a string into a list based on the specified criteria

quoted_split s sep quote_chars esc transform

Parameters
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.
Description

Splits a string into a list based on the specified criteria

remove_left_margin [::woof::util]

util, Top

Removes the left margin from the lines in the specified text

remove_left_margin text args

Parameters
text text string
argsAdditional 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.
Description

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.

scan_http_date [::woof::util]

util, Top

Converts a HTTP formatted date to seconds since the epoch

scan_http_date datestr

Parameters
datestr a date time string formatted as per the HTTP specification
Return value

Returns the date and time as the number of seconds since 0:0:0 Jan 1, 1970.

Description

Converts a HTTP formatted date to seconds since the epoch

tag_attr_fragment [::woof::util]

util, Top

tag_attr_fragment args

Parameters
argsAdditional options.

unmixcase [::woof::util]

util, Top

Converts an mixed case identifier to a lower case one with underscores

unmixcase name

Parameters
name identifier to be converted
Return value

Returns the converted identifier.

Description

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.

url_decode [::woof::util]

util, Top

Decode a www-url-encoded string

url_decode str

Parameters
str the string to be converted
Return value

Returns the decoded string.

Description

Decode a www-url-encoded string

url_encode [::woof::util]

util, Top

Encode a string in www-url-encoded format

url_encode str

Parameters
str string to be encoded
Return value

Returns the encoded string.

Description

Encode a string in www-url-encoded format

Classes

DirtyMap [::woof::util]

util, Top

cleanMarks the object as being unmodified.
clearCalls Map::clear with all arguments and marks the object dirty.
constructorConstructor for the class
dirtyMarks the object as being modified.
dirty?Returns true if the object has been modified since it was constructed and false otherwise
initCalls Map::init with all arguments and marks the object dirty.
lappendCalls Map::lappend with all arguments and marks the object dirty.
setCalls Map::set with all arguments and marks the object dirty.
unsetCalls Map::unset with all arguments and marks the object dirty.
countSee Map.count
existsSee Map.exists
freezeSee Map.freeze
getSee Map.get
hgetSee Map.hget
keysSee Map.keys
lazy_loadSee Map.lazy_load
popSee Map.pop
Superclasses

Map

Subclasses

::woof::Session

Inherited and mixed-in methods
Mapcount exists freeze get hget keys lazy_load pop
constructor [::woof::util::DirtyMap]

DirtyMap, Top

Constructs a Map with the additional functionality that state is maintained about whether the contents have been modified.

::woof::util::DirtyMap create args

Parameters
argsAdditional options.
Description

Constructs a Map with the additional functionality that state is maintained about whether the contents have been modified.

clean [::woof::util::DirtyMap]

DirtyMap, Top

Marks the object as being unmodified.

OBJECT clean

Description

Marks the object as being unmodified.

clear [::woof::util::DirtyMap]

DirtyMap, Top

Calls Map::clear with all arguments and marks the object dirty.

OBJECT clear args

Parameters
args passed on to Map::clear
Description

Calls Map::clear with all arguments and marks the object dirty.

dirty [::woof::util::DirtyMap]

DirtyMap, Top

Marks the object as being modified.

OBJECT dirty

Description

Marks the object as being modified.

dirty? [::woof::util::DirtyMap]

DirtyMap, Top

Returns true if the object has been modified since it was constructed and false otherwise

OBJECT dirty?

Return value

Returns true if the object has been modified since it was constructed and false otherwise

Description

Returns true if the object has been modified since it was constructed and false otherwise

init [::woof::util::DirtyMap]

DirtyMap, Top

Calls Map::init with all arguments and marks the object dirty.

OBJECT init args

Parameters
args passed on to Map::init
Description

Calls Map::init with all arguments and marks the object dirty.

lappend [::woof::util::DirtyMap]

DirtyMap, Top

Calls Map::lappend with all arguments and marks the object dirty.

OBJECT lappend key args

Parameters
key passed on to Map::lappend
args passed on to Map::lappend
Description

Calls Map::lappend with all arguments and marks the object dirty.

set [::woof::util::DirtyMap]

DirtyMap, Top

Calls Map::set with all arguments and marks the object dirty.

OBJECT set args

Parameters
args passed on to Map::set
Description

Calls Map::set with all arguments and marks the object dirty.

unset [::woof::util::DirtyMap]

DirtyMap, Top

Calls Map::unset with all arguments and marks the object dirty.

OBJECT unset args

Parameters
args passed on to Map::set
Description

Calls Map::unset with all arguments and marks the object dirty.

Map [::woof::util]

util, Top

clearRemoves all keys matching the specified pattern from the object.
constructorConstructor for the class
countReturns the number of keys in the object.
existsCheck the existence of a key and optionally return its value.
freezeMakes the object read-only.
getRetrieves values associated with keys.
hgetRetrieves the value of a key in HTML encoded form.
initInitialize uninitialized keys.
keysReturns the list of keys contained in the object.
lappendAppends given arguments to the list value for the specified key
lazy_loadAbstract method to fill in missing values for keys.
popRetrieves the value associated with a key and removes the key from the object.
setSets the values of one or more keys in the object.
unsetRemoves one or more keys from the object.
Subclasses

DirtyMap, ::woof::CookiesIn, ::woof::Environment, ::woof::Params, ::woof::Flash

constructor [::woof::util::Map]

Map, Top

Constructs a dictionary-like object with additional functionality.

::woof::util::Map create map

Parameters
map(optional, default ) is a list of key value pairs that will be used to initialize the list
Description

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.

clear [::woof::util::Map]

Map, Top

Removes all keys matching the specified pattern from the object.

OBJECT clear pattern

Parameters
pattern(optional, default *) the pattern to match
Description

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.

count [::woof::util::Map]

Map, Top

Returns the number of keys in the object.

OBJECT count

Return value

Returns the number of keys in the object.

Description

Returns the number of keys in the object.

exists [::woof::util::Map]

Map, Top

Check the existence of a key and optionally return its value.

OBJECT exists key v_val

Parameters
key key whose existence is to be checked
v_val(optional, default ) name of a variable in the caller's context
Description

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.

freeze [::woof::util::Map]

Map, Top

Makes the object read-only.

OBJECT freeze

Description

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.

get [::woof::util::Map]

Map, Top

Retrieves values associated with keys.

OBJECT get args

Parameters
args optional arguments
Description

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.

hget [::woof::util::Map]

Map, Top

Retrieves the value of a key in HTML encoded form.

OBJECT hget key

Parameters
key key whose associated value is to be retrieved
Description

Retrieves the value of a key in HTML encoded form.

An exception is generated if the key does not exist in the object.

init [::woof::util::Map]

Map, Top

Initialize uninitialized keys.

OBJECT init args

Parameters
args a possibly empty list of alternating key value elements. If a single argument is specified, it must itself be such a list.
Description

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.

keys [::woof::util::Map]

Map, Top

Returns the list of keys contained in the object.

OBJECT keys

Return value

Returns the list of keys contained in the object.

Description

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.

lappend [::woof::util::Map]

Map, Top

Appends given arguments to the list value for the specified key

OBJECT lappend key args

Parameters
key
args values to append to the entry
Description

Appends given arguments to the list value for the specified key

lazy_load [::woof::util::Map]

Map, Top

Abstract method to fill in missing values for keys.

OBJECT lazy_load args

Parameters
args keys whose values are to be filled in.
Description

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.

pop [::woof::util::Map]

Map, Top

Retrieves the value associated with a key and removes the key from the object.

OBJECT pop key defval

Parameters
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.
Description

Retrieves the value associated with a key and removes the key from the object.

set [::woof::util::Map]

Map, Top

Sets the values of one or more keys in the object.

OBJECT set args

Parameters
args a list of key value elements. If a single argument is specified, it must itself be such a list.
Description

Sets the values of one or more keys in the object.

The value of each key specified is set to the corresponding specified value.

unset [::woof::util::Map]

Map, Top

Removes one or more keys from the object.

OBJECT unset args

Parameters
args list of keys to be removed
Description

Removes one or more keys from the object.

::woof::wtf

Commands

compile [::woof::wtf]

wtf, Top

compile in

Parameters
in

compile_template [::woof::wtf]

wtf, Top

compile_template in var

Parameters
in
var(optional, default OUT)

html_frag [::woof::wtf]

wtf, Top

html_frag content args

Parameters
content
argsAdditional options.

render [::woof::wtf]

wtf, Top

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.

render ct

Parameters
ct
Description

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.

run_compiled_template [::woof::wtf]

wtf, Top

run_compiled_template ct

Parameters
ct

substify [::woof::wtf]

wtf, Top

substify in var

Parameters
in
var(optional, default OUT)

table [::woof::wtf]

wtf, Top

table data ncols args

Parameters
data
ncols(optional, default 2)
argsAdditional options.
Document generated by Ruff!
© 2016 Ashok P. Nadkarni