[Demexp-dev] Re: Add response: erreur pyhton
Hi there, I succeeded in using the "marshal" module so that I don't get the error below anymore. However, I get an "Internal server error" from the request. Can I add new answers and new questions with the "demo" account? Best Regards. Lyu Bonjour, j'essaye d'appeler la fonction add_response(cookie,quetsion_id,response_desc_t,link_t) et j'obtiens l'erreur suivante sous mod python: File "C:\Program Files\wamp\www\Demexp\python\login.py", line 248, in validate_new_response s.add_response(cookie, this_question[0]['q_id'],new_response,"") ... File "C:\Program Files\Python25\Lib\xmlrpclib.py", line 633, in __dump raise TypeError, "cannot marshal %s objects" % type(value) TypeError: cannot marshal objects Qu'est-ce que ca vous inspire? Merci. Lyu PS: j'ai implemente la fonction de vote. ___ Demexp-dev mailing list Demexp-dev@nongnu.org http://lists.nongnu.org/mailman/listinfo/demexp-dev
Re: [Demexp-dev] Re: Add response: erreur pyhton
Hello Lyu, 2008/3/11, Lyu Abe <[EMAIL PROTECTED]>: > I succeeded in using the "marshal" module so that I don't get the error > below anymore. However, I get an "Internal server error" from the > request. If you get an "internal server error", then the fault is on the side of the demexp server. However I need more details to find what is happening. Can you provide a self-contained Python code that exhibits the issue? > Can I add new answers and new questions with the "demo" account? I think so. But you should use the "test" server (tuxinette.linux-france.org:50065). I've just checked: you can add new questions with the account "demo", password "demo". Yours, d. ___ Demexp-dev mailing list Demexp-dev@nongnu.org http://lists.nongnu.org/mailman/listinfo/demexp-dev
Re: [Demexp-dev] Re: Add response: erreur pyhton
My code looks like that: def validate_new_response(req): global question_list global question_tags global tag_labels global cookie global s global login args = req.form index = int(args['qu_num']) new_response = args['new_response'] ... 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,"") then I get the server error. I think the "dumps" function I use is not appropriate. Lyu David MENTRE a écrit : Hello Lyu, 2008/3/11, Lyu Abe <[EMAIL PROTECTED]>: I succeeded in using the "marshal" module so that I don't get the error below anymore. However, I get an "Internal server error" from the request. If you get an "internal server error", then the fault is on the side of the demexp server. However I need more details to find what is happening. Can you provide a self-contained Python code that exhibits the issue? Can I add new answers and new questions with the "demo" account? I think so. But you should use the "test" server (tuxinette.linux-france.org:50065). I've just checked: you can add new questions with the account "demo", password "demo". Yours, d. ___ Demexp-dev mailing list Demexp-dev@nongnu.org http://lists.nongnu.org/mailman/listinfo/demexp-dev
Re: [Demexp-dev] Re: Add response: erreur pyhton
Hello Lyu, 2008/3/11, Lyu Abe <[EMAIL PROTECTED]>: > 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. ___ Demexp-dev mailing list Demexp-dev@nongnu.org http://lists.nongnu.org/mailman/listinfo/demexp-dev
Re: [Demexp-dev] Re: Add response: erreur pyhton
Hi again, I got this error: == File "C:\Program Files\wamp\www\Demexp\python\login.py", line 335, in validate_new_response s.add_response(cookie,this_question[0]['q_id'],new_response.encode('utf8'),new_response_link.encode('utf8')) File "C:\Program Files\Python25\Lib\xmlrpclib.py", line 1147, in __call__ return self.__send(self.__name, args) File "C:\Program Files\Python25\Lib\xmlrpclib.py", line 1437, in __request verbose=self.__verbose File "C:\Program Files\Python25\Lib\xmlrpclib.py", line 1201, in request return self._parse_response(h.getfile(), sock) File "C:\Program Files\Python25\Lib\xmlrpclib.py", line 1340, in _parse_response return u.close() File "C:\Program Files\Python25\Lib\xmlrpclib.py", line 787, in close raise Fault(**self._stack[0]) Fault: and the same error for new_question: Fault: I am using the demo/demo account. Lyu David MENTRE a écrit : Hello Lyu, 2008/3/11, Lyu Abe <[EMAIL PROTECTED]>: 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. ___ Demexp-dev mailing list Demexp-dev@nongnu.org http://lists.nongnu.org/mailman/listinfo/demexp-dev
Re: [Demexp-dev] Re: Add response: erreur pyhton
Hi David, Well, I don't really understand why you would need such marshal calls. Because at first I got an error message mentionning "Cannot marshal %s objects" (see my other mail in the comments) For the new_question and add_response, I will send you a test code by this evening. Regards, Lyu ___ Demexp-dev mailing list Demexp-dev@nongnu.org http://lists.nongnu.org/mailman/listinfo/demexp-dev
Re: [Demexp-dev] Re: Add response: erreur pyhton
Hi Lyu, 2008/3/12, Lyu Abe <[EMAIL PROTECTED]>: > Because at first I got an error message mentionning "Cannot marshal %s > objects" (see my other mail in the comments) Ok. In fact, I thought you were using ONC RPC instead of XML RPC. So my comments were pretty useless in your case. > For the new_question and add_response, I will send you a test code by > this evening. Ok, I'll test it. Yours, d. ___ Demexp-dev mailing list Demexp-dev@nongnu.org http://lists.nongnu.org/mailman/listinfo/demexp-dev
Re: [Demexp-dev] Re: Add response: erreur pyhton
"Good evening Dave" Here is a piece of code that produces the error. If you have Mod Pyhton installed, you need to include the following to the httpd.conf file: LoadModule python_module modules/mod_python.so and AddHandler mod_python .py PythonHandler mod_python.publisher PythonDebug On Let me know what you think... Lyu ___ Demexp-dev mailing list Demexp-dev@nongnu.org http://lists.nongnu.org/mailman/listinfo/demexp-dev
Re: [Demexp-dev] Re: Add response: erreur pyhton
Hello Lyu, Lyu Abe <[EMAIL PROTECTED]> writes: > "Good evening Dave" :-) "Everything is going extremely well." > Here is a piece of code that produces the error. In fact, your code works perfectly if you make this little change: --- login.py.orig 2008-03-14 22:53:40.0 +0100 +++ login.py2008-03-14 23:06:19.0 +0100 @@ -39,7 +39,7 @@ login = login_in password = password_in - url = "http://www.linux-france.org/cgi-bin/demexp-xmlrpc-demo"; + url = "http://www.linux-france.org/cgi-bin/demexp-xmlrpc-test"; s = ServerProxy(url) cookie = s.login(login, password) In other words, use the test server instead of the demo one. The explanation is pretty simple: the XML RPC proxy for the demo server does *not* have the add_response() method (and probably others)! :-/ So use http://www.linux-france.org/cgi-bin/demexp-xmlrpc-test and everything should go smoothly. Yours, d. -- GPG/PGP key: A3AD7A2A David MENTRE <[EMAIL PROTECTED]> 5996 CC46 4612 9CA4 3562 D7AC 6C67 9E96 A3AD 7A2A ___ Demexp-dev mailing list Demexp-dev@nongnu.org http://lists.nongnu.org/mailman/listinfo/demexp-dev
Re: [Demexp-dev] Re: Add response: erreur pyhton
Hi David, "Good evening Dave" :-) "Everything is going extremely well." Hehe ;) Here is a piece of code that produces the error. In fact, your code works perfectly if you make this little change: --- login.py.orig 2008-03-14 22:53:40.0 +0100 +++ login.py2008-03-14 23:06:19.0 +0100 @@ -39,7 +39,7 @@ login = login_in password = password_in - url = "http://www.linux-france.org/cgi-bin/demexp-xmlrpc-demo"; + url = "http://www.linux-france.org/cgi-bin/demexp-xmlrpc-test"; s = ServerProxy(url) cookie = s.login(login, password) In other words, use the test server instead of the demo one. The explanation is pretty simple: the XML RPC proxy for the demo server does *not* have the add_response() method (and probably others)! :-/ So use http://www.linux-france.org/cgi-bin/demexp-xmlrpc-test and everything should go smoothly. Great! That's good news. I'll keep on working on the code. I hope I can release a functionnal version within 2 or 3 weeks from now. Regards, Lyu ___ Demexp-dev mailing list Demexp-dev@nongnu.org http://lists.nongnu.org/mailman/listinfo/demexp-dev