File organization of todomgr.tcl
[ Previous: index ]
[ Top: To-do manager ]
[ Next: Database schema of the task list ]
Most people are familiar with the Apache/CGI model of active content, where an action is
defined as a file (the CGI program) which is activated when selected via URL. AOLserver
does things a little differently. Well, you can do things that way by putting your Tcl
code into a plain ol' Tcl file. But I use the ns_register call to define some
URLs as active URLs, and tell the server what Tcl procedure to call when a request is
made to that URL. It's a slick mechanism.
AOLserver/Tcl code of this type consists of calls to ns_register
, perhaps some
settings for global variables, and proc
definitions.
Let's start our file off with a little copyright info:
|
# To-do manager, take 1.
# Copyright (c) 2000, Vivtek.
# Released under the terms of the GNU license.
|
And let's set two globals: the home directory and the base URL for the application. Oh, and
the database connection pool to use.
|
set todomgr_home /usr/local/AOLserver/vivtek/pages/todomgr/
set todomgr_root /todomgr
set todomgr_pool wftk
|
Now let's define the URLs we want to use:
|
ns_register_proc GET $todomgr_root/create todomgr_create
ns_register_proc POST $todomgr_root/create todomgr_create
ns_register_proc GET $todomgr_root/start todomgr_start
ns_register_proc POST $todomgr_root/start todomgr_start
ns_register_proc GET $todomgr_root/show todomgr_show
ns_register_proc POST $todomgr_root/show todomgr_show
ns_register_proc GET $todomgr_root/complete todomgr_complete
ns_register_proc POST $todomgr_root/complete todomgr_complete
ns_register_proc GET $todomgr_root/reject todomgr_reject
ns_register_proc POST $todomgr_root/reject todomgr_reject
ns_register_proc GET $todomgr_root/update todomgr_update
ns_register_proc POST $todomgr_root/update todomgr_update
ns_register_proc GET $todomgr_root/overview todomgr_overview
|
(Notice that in Tcl you don't have to enclose strings in quotes if the interpreter can figure
things out from context. This causes me no end of grief when coding Perl.)
And let's go ahead and define each of our procedures that we're referring to up there. The
bodies of these procedures will be filled in later.
And there are a few utility functions that I'll be using throughout:
todomgr_pageout
is what I'll use to write pages, and there are some others in the
final section of the presentation.
(5/10/2000) Let's toss in a couple more procs to deal with datasheet manipulation (the
getting and setting of values attached to the process and to tasks.)
[ Previous: index ]
[ Top: To-do manager ]
[ Next: Database schema of the task list ]
This code and documentation are released under the terms of the GNU license. They are
additionally copyright (c) 2000, Vivtek. All rights reserved except those explicitly
granted under the terms of the GNU license.
|