Request Dictionary
Overview
Each request to the HTTP server mod sets up a request dictionary. Its life time is limited only to this one request processing time and after that it is cleaned up. The module which provides an API to it is wparts, however it was introduced only to improve the handling of dictionary values. It was the developers decision to break the framework idea of calling the request dictionary through the wpart application and work directly with eptic — it gives some advantages in specific situations.
Usage
In general, it is possible to set {Key, Value} and later get those values from the dictionary (they will be stored under the Key). Presented below is a list of functions operating on the request dictionary.
Request dictionary API
Wpart API
The API of the dictionary covers three functions: fset/2, finsert/2, fget/1. Although fset takes only two arguments {Key, Value}, though it is possible to create deeper structures. To separate parent node from leaves in the Key, a : (colon) is used. The wpart API uses only string as keys, thanks to that it is possible to call the dictionary from the View application level (wpart:lookup look for spec in Manual).
How to put values into the dictionary?
fset/2: wpart:fset("SomeKey", SomeVal) - All different values stored under the Key are in the dictionary during request time.
fset/2: wpart:fset("List:Key",Val) - It is possible to create related values in one table.
finsert/2: wpart:finsert("key", Val) - Analogical structure like fset but replaces values if the key is the same
How to get values from dict?
fget/2: wpart:fget("SomeKey")
fget/1: wpart:fget("People:Developers")
If there is more than one value stored in a key, the function returns a list of all values.
Low level calls API
Setting values:
fset/2: eptic:fset("some key", SomeVal) - Multiple values can be stored to a single key. This is major change from version 1.0. It has been implemented because HTML has some tag constructions which do not allow to set name parameters in dependent tags - just the cover tag has it.
fset/3: eptic:fset("list","key",Val) - Possible to create family of values in one table.
finsert/2: eptic:finsert("key", Val) - Analogical structure like fset but replaces values if the key is the same.
Recovering values:
fget/1: eptic:fset("some key")
fget/2: eptic:fget("post","name1") - If more than one value is stored in a key, the function returns a list of all values.
Special cases
The dictionary is also used by the framework. E.g. POST messages from the browser go to it. Each message on the framework side is passed by request to the dictionary and starts with a double underscore. Because of backward compatibility issues, some of them still are not. Below is the list of restricted keys.
key |
description |
__https |
bool() |
__controller |
current controller |
post |
POST variables |
get |
GET variables |
__not_validated |
record from form which failed validation |
__error |
reason of validation failure |
__types |
dynamic feed for types addressed to wpart_derived |
__edit |
default or initial values for derived to fill up form |
session |
session talks to session table in ETS via e session which synchronize them |
__path |
hold URL of the current request |
__primary_key |
identifies values during an update |
__cookies |
list of tuples: {CookieName, CookieVal} related to the service |
__ip |
client's IP address, a four element tuple of integers {A, B, C, D} |
