pickled objects over http
dsavitsk
dsavitsk at e-coli.net
Mon Apr 9 23:30:32 EDT 2001
hello again:
i am trying to run scripts on an http server (iis) which produces pickled
objects to be returned. everything is okay (the scripts run and when the
pickles are viewed in a browser they look like pickles in text files),
except i am unable to figure out how to unpickle them once gotten.
here is the cgi script ...
------------------------------------
import pickle
def test():
x = {}
x['name'] = 'doug'
x['id'] = '123456789'
a = pickle.dumps(x)
return a
print "Content-Type: text/plain\n\n"
print
print str(test())
------------------------------------
and a client ...
------------------------------------
import httplib
import pickle
h = httplib.HTTP('server')
h.putrequest('GET', '/path/to/script.cgi')
h.putheader('Accept', 'text/plain')
h.endheaders()
a,b,c=h.getreply()
f = h.getfile()
x = pickle.loads(f.read())
print x['name']
------------------------------------
can anyone help me to do this?
thanks,
doug
More information about the Python-list
mailing list