demexp-dev
[Top][All Lists]
Advanced

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

Re: [Demexp-dev] Re: Add response: erreur pyhton


From: David MENTRE
Subject: Re: [Demexp-dev] Re: Add response: erreur pyhton
Date: Tue, 11 Mar 2008 23:16:26 +0100

Hello Lyu,

2008/3/11, Lyu Abe <address@hidden>:
>         this_question = s.question_info(cookie, index, 1)
>         marshalled_qu = marshal.dumps(this_question[0]['q_id'])
>         marshalled_resp = marshal.dumps(new_response)
>         s.add_response(cookie, marshalled_qu,marshalled_resp,"")

Well, I don't really understand why you would need such marshal calls.

If you look at the code of the XML RPC proxy, you see for example this
code to add a new response (line 157):

    def add_response(self, cookie, question_id, response_desc, response_link):
        ret = self.onc.add_response(cookie, question_id,
                                    response_desc.encode('utf_8'),
                                    response_link.encode('utf_8'))
        if ret != DemexpRpc.const.rt_ok:
            raise RpcError(ret)
        return ret

"cookie" is the cookie you got from login().

"question_id" is a Python integer.

"response_desc" and "response_link" are two Python strings.

When you use ONC RPC calls, you can use regular Python simple types as
arguments. Where are those marshal calls coming from?

You'll find other examples of Python code to call the demexp server in
the source code of pydemexp (http://thomas.enix.org/pub/pydemexp/), in
files "add-question.py" and "list-question.py".

If you are able to get your new response as a regular Python string,
you should be able to add it to the server pretty easily.

I hope this helps,
Yours,
d.




reply via email to

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