Special object names
Form:
=====
When a request is submitted through a an html form a `var` object of name 'form'
is intialised with properties of the html form. A form can be submitted either
through post or get operation by browser, using urlencoding or multipart-mime.
In the caravan process that services this request an object of name 'form' predefined.
So caravan script can directly access the request parameters by their propery names as:
form(propertyname);
Lets say we have an html form like this:
The browser will provide an input text box and a submit button. When the user
enters some text in the text box and clicks on the submit button test.html
will be invoked by caravan in a separate thread.
in test.html say we want to to just display the input
"you typed : ";form(subject);"
"
The properties so initialised are in read only mode and caanot be changed by user code.
ie.
Form(subject)="some text";// will have no effect if subject is input from the client.
form(text)="Hello world\r\n"; // this will add a new property 'text' to 'form'
Sql:
====
Caravan select statemants are of the form:
select from tbl where fieldname=value
where 'tbl 'is the name of a `table` object, 'fieldname' is one of its fields and 'value' is the select criteria.
Most of the time the select statements have to generated from dynamically. In this case the select statement is
written as:
select from tbl where fieldname={value}
The curly bracket implies that 'value' is the property of an object of name 'sql' or 'form'.
Example:
table tbl=cab.users;// there is a table users.data in cab.db
//The following statements are equivalent
select from tbl where name="john Doe"
//or
var sql
sql(input)="John Doe"
select from tbl where name="{input}"
//or
// usually an html 'form' has been submitted with the property 'input'
// this avoids the steps -- var sql;sql(input)=form(input)
select from tbl where name="{input}"
// if both 'form' and 'sql' exists then sql is used.
request:
========
An object with name 'request' is initialised with caravan configuration and other info for every caravan
template that runs as a process:
request has follwing properties:
address :
IP address of the requesting client
tmp :
The path setup for temporary files
documents :
The path setup for static documents
hits :
The number of requests served.
timestarted :
The time value when caravan started
userinfo:
=========
On authentication an object containing the properties of the user is available for all subsequent requests
from this client.
userinfo has following properties:
username; username of the logged in user
uid; a numeric id
userid: login name
link;a numeric value which can be used access additional info from another table
domain: domain of this user
_response:
==========
When a response is given to the client from a caravan templte sometimes
one would like to set the properties of the response document.
Any http header info can be used as the property of this object except content-length -- content-length
is always equal to the size of the document in bytes.
Some common properties that can be set are:
content_type: tells browser how to display
cache_control: tells the browser how to cache
expires: tells the browser when to expire this fromm cache
example
var _response;// creates an object of name _response
_response(content-type)="text/plain";// treat this as text
_reponse(cache-control)="no-cache";// dont cache
"hello world\r\n"
"This is plain text\r\n"
_reply:
========
When a post or put operation is executed by a object of type 'form' the _reply object is created
which contains following properties, in addition to the properties set by the remote http server.
_reply(error);// error if any of the post/put action
_reply(content);// contents of server's reply
_reply(content-length);// content-length of the server's reply in bytes
_event:
=======
This the name of the queue object that is created using eventhandler statement. This is in
all respects like any queue object created using the queue decaration.