Pickle in a POST/GET request give EOFError

Romaric DEFAUX rde at audaxis.com
Tue Nov 16 17:47:21 CET 2010

Hi everybody !

First time I write to this mailing list :)
I started writing in python last week, that's probably why I can't 
understand the following problem...

I create a list called web_site_list.
This list contain dictionaries called web_site.
And some values in this dictionaries are list too.

I do that in a function and I return this :
return pickle.dumps(web_site_list)

This is working fine :)

If I do :
print "%s" % pickle.loads(system.get_web_site_list())

I've got the right stuffs. For example it returns :
[{'documentroot_size': '120', 'servername': '---default---', 'client': 
'undefined', 'documentroot': '/var/www/', 'client_contact': 'undefined', 
'serveralias': []}]

I send this to a web service. I send it like that :
#I put it in params
def system_updateweb_site(server, login, password):
         params = {}
         params['login'] = login
         params['password'] = password
         params['action'] = 'updateweb_site'
         params['servername'] = get_servername()
         params['hosted_web_site'] = get_web_site_list()
         return call_system_ws(server, params)

#Here's how I send it (I tried in GET and POST)
def call_system_ws(host, params):
         query_string = urllib.urlencode(params)
#       f = urllib.urlopen("http://%s/ws?%s" % (host, query_string))
         f = urllib.urlopen("http://%s/ws" % (host), query_string)
         result = f.readline().strip()
         if result == 'ERROR':
                 msg = f.readline().strip()
                 return (False, msg)
         return (True, result)

On the server side :
                         if action == 'updateweb_site':
                                 if not (fields.has_key('servername') 
and fields.has_key('hosted_web_site')):
                                         raise WSError('missing 
parameter : servername or hosted_web_site')
                                         log ('ERROR : missing parameter 
: servername or hosted_web_site')
                                         output = 
systemserver.updateweb_site(cursor, servername, hosted_web_site)

In systemserver.py :
def updateweb_site(cursor, host, hosted_web_site):
         web_site_list = pickle.loads(hosted_web_site)
         return "%s" % (web_site_list)

I catch this error :*

<type 'exceptions.EOFError'>*:

args = ()
message = ''

Why ?

If I just print hosted_web_site, I get this on my web page :


It's the "pickled view" of
[{'documentroot_size': '120', 'servername': '---default---', 'client': 'undefined', 'documentroot': '/var/www/', 'client_contact': 'undefined', 'serveralias': []}]

Can someone help me please ? I spend my afternoon to google to try to 
find a solution...

Thanks in advance !!!

Romaric Defaux

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5361 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20101116/a2210bf9/attachment.bin>

More information about the Python-list mailing list