Creation
web::context
name
Creates a namespace name with the following commands:
name
::subcommand
args
Subcommands are: cset, cappend, clappend, cget, cexists, cunset, carray, cnames, delete, and dump. Manages data of the context. The subcommands behave like the Tcl commands with similar names.
name
::cset
key
value
name
::cappend
key
value
?value
?
?...
?name
::clappend
key
value
?value
?
?...
?name
::cget
key
?default
?name
::cexists
key
name
::cunset
key
name
::carray
option
key
arg
name
::cnames
?pattern
?name
::deletename
)
name
::dump
Example 12. web::context
% web::context sc % sc::cset lang FR FR % # ... some code ... % set lang [sc::cget lang EN] FR %
Creation:
web::filecontext
name
?options
?Options are: -perm, -path, -crypt, -idgen, and -attachto. Creates a namespace name to manage file-based context data:
name
::subcommand
args
Subcommands are: cset, cappend, clappend, cget, cexists, cunset, carray, cnames, init, new, commit, invalidate, and id. Manages file-based context data. The subcommands have their familiar behaviour of the Tcl commands with similar names. Please refer to the section context management for a description of the commands cset, cappend, clappend, cget, cexists, cunset, carray, and cnames.
name
::init
?id
?
name
::new
?id
?name
::commitname
::idname
::invalidateOptions:
web::filecontext
name
-perm perm
Sets the file permissions of the session context files perm is an unix-like octal value like 0644. If not specified, files are created with the permissions defined in web::config filepermissions, which again defaults to 0644.
name
-path
path
../data/s99.dat
.
name
-crypt
booleanname
-idgen
idgen
name
-attachto
idparam
name
::init
to initialize with the id given in the querystring parameter
idparam. (This is one important reason why
the querystring should be encrypted). After
web::dispatch has
parsed the querystring, web::param
will report the current session id in
idparam, if any. Note
that you can maintain several sessions in parallel,
and attach every session to its own
idparam.
Note: Whenever you create a new file-based context, the context is initialized and you loose whatever information that you might have stored in the context before you initialized it as a file-based session context.
Creation:
web::cookiecontext
name
?options
?Options are: -expires, -path, -domain, -secure, -crypt, and -channel. Creates a namespace name to manage cookie-based context data:
name
::subcommand
args
name
::init
?id
?name
::new
?id
?name
::commitname
::idname
::invalidateOptions:
name
-expires
time
name
-path
path
name
-domain
domain
name
-secure booleanname
-crypt
booleanname
-channel
channelName
Because cookies are client-based, in principle no id is needed. Websh uses id to name the cookie, however, and the new, init, and load commands still require the id argument. (fixme: any changes?) Please note that property settings of a cookie context can only be changed before anything is output on the respective channel.
This is a numeric sequence-number generator which stores its state in a file. Basic usage:
name
-filename
fname
?options
?
filename
value
value
value
value
value
After creation, a new command name is registered with the following subcommands:
name
configname
nextvalname
curvalname
getval
Example 13. web::filecounter
% web::filecounter fc1 -filename test.dat fc1 % fc1 config file test.dat handle fc1 seed 0 min 0 max 2147483647 incr 1 perms 0644 wrap false curr {not valid} % fc1 curval web::filecounter: no current value available % fc1 nextval 0 % fc1 config file test.dat handle fc1 seed 0 min 0 max 2147483647 incr 1 perms 0644 wrap false curr 0 % fc1 nextval 1 % web::filecounter fc2 -filename test.dat fc2 % fc2 curval web::filecounter: no current value available % fc2 getval 1 % fc2 nextval 2 % fc2 curval 2 % fc1 curval 1 % fc1 nextval 3 % fc2 getval 3 % web::filecounter fc3 -filename othertest.dat -min 1 -max 10 -seed 1 -incr 2 -wrap 1 fc3 % fc3 config file othertest.dat handle fc3 seed 1 min 1 max 10 incr 2 perms 0644 wrap true curr {not valid} % fc3 nextval 1 % fc3 nextval 3 %