tclhttpd

Update of ”DirectOO”
Login

Update of ”DirectOO”

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview

Artifact ID: 8a3878cc7baa55e892f690b5c24812361ac3a6b4
Page Name:DirectOO
Date: 2015-04-02 01:47:06
Original User: hypnotoad
Mimetype:text/x-markdown
Parent: dafe65da4a0086ab838b191409e2235df3f2bde9 (diff)
Next a69e3ad2b85a282b823ee10a7f57b9030173d7ae
Content

Getting Started

DirectOO is a new feature in Tclhttpd 4.0. It's goal is to allow applications to be built around TclOO, as well as to allow for more flexible handling of virtual paths.

Implementation

To use DirectOO:

package require httpd::directoo

httpd.url create WEBOBJ /test

The httpd.url class

httpd.url is a TclOO class. The first argument (after the name of the new object) is the virtual root for this object. For more complex classes, the second argument is a key/value list of configuration options. Any arguments after that are passed to Url_PrefixInstall

Variables

env

An array which contains CGI data. It is populated every page view Cgi_SetEnv in Tclhttpd.

result

An array which contains the meta information and content about the page view in progress. Important fields:

Methods

configurelist keyvaluelist

Pass configuration items as a key/value list.

cget field

Retrieve the value of a configuration item

/html

A method which implements the default root page of the object.

initialize

A method which is called in the constructor, after the configuration items have been applied and the domain registered with Tclhttpd.

httpdDirect sock suffix

This method is the first called when resolving a dynamic page. It calles httpdSessionLoad to load the session, httpdMarshalArguments do compute the method to call. On error, this method returns an error message. On success it calls httpdSessionSave, before sending the resulting data out to TclHttpd via the Httpd_ReturnData or Httpd_ReturnCacheableData procs.

httpdMarshalArguments sock suffix

Calculate the command which will implement the current page view.

httpdSessionLoad sock *prefix suffix

Initializes the result variable, and load session data from either cookies or the incoming GET/POST query. This method also calls the Cgi_SetEnv and Url_QuerySetup procs from Tclhttpd. Rather than populate the global env variable, Cgi_SetEnv populates the private env variable for this object.

httpdSessionSave sock

Updates the current session, and writes cookies back to the browser.

reset

Reset the current value of result(body)

puts

Append to the value of result(body). Accepts multiple arguments. An implied n is appended at the tail end.

unknown args

Handler for unknown, incomplete, or invalid queries.