AOLserver and Tcl Crash Course

From AOLserver Wiki
Jump to navigation Jump to search

The following is a working draft in progress for an introductory guide to AOLserver and Tcl.

ADP Pages

Hello <Yourname> - Simple page, user submits form, displays name

ADP example

hello-world.adp:

<% set name [ns_queryget name "world"] %>
<html>
<head>
  <title>Hello <%= [ns_quotehtml $name] %>!</title>
</head>
<body>
  <p>Hello <%= [ns_quotehtml $name] %>!</p>
  <form>
  <p>Name: <input name="name" value="<%= [ns_quotehtml $name] %>"></p>
  <p><input type="submit" value="Go"></p>
  </form>
</body>
</html>

Tcl example

hello-world.tcl:

set name [ns_queryget name "world"]
ns_return 200 text/html "<html>
  <head>
    <title>Hello [ns_quotehtml $name]!</title>
  </head>
  <body>
    <p>Hello [ns_quotehtml $name]!</p>
    <form>
    <p>Name: <input name="name" value="[ns_quotehtml $name]"></p>
    <p><input type="submit" value="Go"></p>
    </form>
  </body>
  </html>"

Tcl Basics

    • Explain Minimalist Syntax
      • Commands, Subcommands (Evaluated and Non-Evaluated)
      • Working with variables set, expr
    • Control Structures
      • if, while, etc.
      • procedures

Fetching GET and POST

    • Including / Referring to other pages
    • Controlling Output
    • Databases
      • Defining the connection from as a pool in the config.tcl
      • Selecting from the pool
      • Executing Queries, Retrieving Values

Questions

  • Where does ADP excel?
  • What practices should PHP, ASP, JSP developers stop doing?
  • How can one use Tcl to write very concise and readable code?
  • How does one efficiently separate pages into MVC components if the wanted?
  • How and why should one write a domain specific sublanguage?