demexp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Demexp-dev] First XML RPC proxy available


From: David MENTRE
Subject: Re: [Demexp-dev] First XML RPC proxy available
Date: Sun, 03 Sep 2006 19:59:07 +0200
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux)

David MENTRE <address@hidden> writes:

> Ok, after looking at XML RPC specs a bit and looking at some Python
> code, it appears that in fact I could return a <fault> structure in case
> of error (with the <faultCode> field containing the demexp error code,
> and the <faultString> the appropriate demexp error string). 

Ok, I once again chaned my mind and used <fault> to report errors. That
gives:

>>> s = ServerProxy("http://www.linux-france.org/cgi-bin/demexp-xmlrpc-demo";)
>>> s.login("demo", "demo")
331256138
>>> s.login("demo", "dem")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.3/xmlrpclib.py", line 1032, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.3/xmlrpclib.py", line 1319, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.3/xmlrpclib.py", line 1083, in request
    return self._parse_response(h.getfile(), sock)
  File "/usr/lib/python2.3/xmlrpclib.py", line 1222, in _parse_response
    return u.close()
  File "/usr/lib/python2.3/xmlrpclib.py", line 745, in close
    raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 410: 'rt_bad_login'>
>>> s.max_question_id(0)
270
>>> s.question_info(0, 0, 1)
[{'q_id': 0, 'q_info_num_votes': 21, 'q_info_limit_date': 0, 'q_desc': 'Est-ce q
ue vous trouvez demexp utilisable ?', 'q_info_elected_responses': [2], 'q_timest
amp': 24115814, 'q_info_status': 2, 'q_info_responses': [{'r_info_desc': 'Questi
on rejected', 'r_info_link': ''}, {'r_info_desc': u'Ind\xe9cis', 'r_info_link': 
''}, {'r_info_desc': 'Oui', 'r_info_link': ''}, {'r_info_desc': 'Non', 'r_info_l
ink': ''}, {'r_info_desc': u'm\xeame le dimanche?', 'r_info_link': ''}, {'r_info
_desc': 'oui', 'r_info_link': ''}, {'r_info_desc': u'Uniquement avec un \xe9cran
 large', 'r_info_link': ''}, {'r_info_desc': 'A qd la langue francaise ?', 'r_in
fo_link': ''}, {'r_info_desc': 'NON', 'r_info_link': ''}, {'r_info_desc': 'Diffi
cile pour un non informaticien', 'r_info_link': ''}]}]

I think this is cleaner and simpler on the XML RPC side. Let me know if
you disagree.

Best wishes,
d.
-- 
GPG/PGP key: A3AD7A2A David MENTRE <address@hidden>
 5996 CC46 4612 9CA4 3562  D7AC 6C67 9E96 A3AD 7A2A




reply via email to

[Prev in Thread] Current Thread [Next in Thread]