.STRUM -> DE/TH: The Easy Way to Get REST
October 10, 2005 § Leave a comment
simpler?
The endgame is always
DE/TH:
Encoding/Transmitting
HTML
or
DHTML
Encoding/Transmitting
Hashtables
maximize
your happiness
is to
die
to your happiness
for something bigger than
your
happiness.
Click [Read More] for the
technical description.
in HTML, such that they can be sent back and forth via HTTP and REST URIs. That
is, every page is both human-readable *and* decomposable into dictionaries which
can trivially be used to invoke it as a web
service.
This can be considered a
microformat allowing machine-processing of Anchors and Forms. For concreteness,
this describes the structures in terms of Python dictionaries, thought the
implementation-side processing is not visible from DETH proper: we never know
what happens on the other side of DETH.
😉
A. Dictionaries (key-value pairs)
are the primary data type
“key=value”
->
<dt>key</dt><dd>value</dd>
“@key=value”
-> <dl key=”value”>
“@@tag=element,
@@body=content”
->
<element>content</element>
dictionaries
regular/extra key:value
entries)
Example
A.1:
pydict={“@class”:”xoxo”,
“key”:”value”, “a”:”b”} ->
<dl
class=”xoxo”>
<dt>key</dt><dd>value</dd>
<dt>a</dt><dd>b</dd>
</dl>
Example
A.2:
pydict={“@@tag”:”a”,
“@href”:”http://www.opendarwin.org/”, “@@body”:”%40opendarwin”, “a”:”b”}
-> < a
href=”http://www.opendarwin.org/“>@opendarwin<
/a>
->
@opendarwin
B.
Lists are a supporting data type. Two forms:
‘@@tag’ for “ul”).
“<li>item</li>”
keys
@@order
Example
B.1:
pylist=[“a”,”b”,”D”,”c”]
pydict1={“key”:
pylist}
->
<dl>
<dt>key</dt><dd><ol>
<li>”a”</li><li>”b”</li><li>”D”</li><li>”c”</li>
</ol></dd>
</dl>
Example
B.2:
pydict2={“@@tag”: “ul”,
@@order=pylist}
->
<ul>
<li>”a”</li>
<li>”b”</li>
<li>”D”</li>
<li>”c”</li>
</ul>
C.
Tables are extended
lists:
<table><tr><td>
@@order specifies columnal header (<th>)
cells
@@body specifies list of data
dictionaries
@@order is empty
@@body is list of lists (all same
size)
Example
C.1:
pyorder=[“c”,”b”,”a”]
pydata=[
{“a”:”apple”,”b”:”banana”,”c”:”cantaloupe”},
{“b”:”bus”,”a”:”auto”,”c”:”car”}]
pydict={“@@tag”:”table”,
“@@body”: pydata, @@order=pylist}
->
<table>
<tr><th
scope=”col”>c</th> <th scope=”col”>b</th> <th
scope=”col”>a</th></tr>
<tr><td>cantaloupe</td><td>banana</td><td>apple</td></tr>
<tr><td>car</td><td>bus</td><td>auto</td></tr>
</table>
Example
C.2:
pydata=[
[71,89,17],[Ê5,59,113],[101,29,47]]
pydict={“@@tag”:”table”,
“@@body”: pydata}
->
<table>
<tr><td>71</td><td>89</td><td>17</td></tr>
<tr><td>5</td><td>59</td><td>113</td></tr>
<tr><td>101</td><td>29</td><td>47</td></tr>
</table>
D.
Forms are special
tables:
<form><label><input>
Example
D.1:
pyorder=[“name”, “sex”,
“submit”,
“reset”]
pydict={“@@tag”:”form”,
“@action”:”http://somesite.com/adduser“,
“@method”:”post”,
“@@order”:pyorder
name:”Name:
“,
“sex”:{“@@body”:”Sex: “,@type=”radio”,
“male”:”Male”,”female”:”Female”},
“age”:{@type=”select”, “child”:”<
18″,”adult”:”18-64″,”senior”:”65+”},
“submit”:”Send”,
“reset”:””,
}
->
<form
action=”http://somesite.com/adduser”
method=”post”>
<label
for=”name”>Name: <input type=”text” id=”name”
/></label>
<label
for=”sex”>Sex:
<input type=”radio”
name=”sex” id=”sex”
value=”male”>Male</input>
<input type=”radio” name=”sex” id=”sex”
value=”female”>Female</input>
</label>
<select
name=”age”>
<option
value=”child”>< 18</option>
<option
value=”adult”>18-64</option>
<option
value=”senior”>65+</option>
</select>
<input type=”submit”
value=”Send”>
<input
type=”reset”>
Leave a Reply