DETH Python Bindings

October 11, 2005 § Leave a comment

Here’s an attempt to show how DETH data-structures get mapped onto Python
dictionaries.

The idea is that as a
client I could do something
like:

=====
import
deth

dict=deth.getDict(“http://somesite.com/users/“)
dict[“firstname”]=”Ernie”
dict[“lastname”]=”Prabhakar”

nextDict=deth.postDict(dict,
http://somesite.com/users/“)

=====

And
hopefully something just as simple on the server. It would be nice to have a
cgi or something that would turn the url-encoded key-value pairs into a XOXO
‘dl’ entry, and simply pass that XHTML document over stdin. My server could
then just
do:

=====
import
deth

import
sys

doc=””
for
line in sys.stdin:


doc=doc+line

if “</html>” in
line:


dict=deth.HTMLtoDict(doc)


result=processDict(dict) # whatever


outDoc=deth.dicttoHTML(result)


sys.stdout.write(outDoc)


doc=””

=====


order=[


"firstname","lastname","sex",'"travel",
"age","description"


]


dict={


"@@tag":"form",


"@action":"http://somesite.com/users/",


"@class":"deth",


"@enctype":"application/x-www-form-urlencoded",


"@method":"post",


"@@order":order,


"firstname":"First name:",


"lastname":"Last name:",


"sex":{"@type":"radio", "male":"Male",
"female":"Female"},


"travel":{"@type":"checkbox", "car":"Car",
"bike":"Bicycle"},


"age":{"@@body":"Age:",
"@type":"select",


"0":"< 18", "18":"18-64",
"65":"65+"


},


"description":{


"@@body":"Description:",


"@type":"textarea",


"@value":"Default text"


}

}

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

What’s this?

You are currently reading DETH Python Bindings at iHack, therefore iBlog.

meta

%d bloggers like this: