Pylons / pyramid_rpc

RPC plugins for pyramid. XML-RPC, JSON-RPC, etc.
https://docs.pylonsproject.org/projects/pyramid-rpc/en/latest/
Other
27 stars 19 forks source link

config.scan not found @xmlrpc_method #22

Closed sdayu closed 11 years ago

sdayu commented 12 years ago

I try to install pyramid 1.3.2 in new environment. When i ran old application I got xmlrpclib.Fault: <Fault -32601: 'server error; requested method not found'> My application use pyramid_rpc with @xmlrpc_method to config endpoint. I try to change @xmlrpc_method to config.add_xmlrpc_method, it work. I am not sure It is my mistake or pyramid 1.3.2 not support @xmlrpc_method

mmerickel commented 12 years ago

My first guess is that you aren't scanning the modules containing the @xmlrpc_method calls. Do you think you can submit a failing test case, or some example code that breaks?

sdayu commented 12 years ago

I am sure that pyramid application scan the modules containing the @xmlrpc_method because in this module I have other view use @view_config this function can run normally. On the way I try to run test case and show you.

sdayu commented 12 years ago

This result when i ran unittest:

$ python -m unittest -v test_xmlrpc test_normal (test_xmlrpc.TestParseXMLRPCRequest) ... ok test_toobig (test_xmlrpc.TestParseXMLRPCRequest) ... ok test_xmlrpc_endpoint (test_xmlrpc.TestXMLRPCEndPoint) ... ok test_xmlrpc_endpoint_not_found (test_xmlrpc.TestXMLRPCEndPoint) ... ok test_add_xmlrpc_method_with_no_endpoint (test_xmlrpc.TestXMLRPCIntegration) ... ok test_add_xmlrpc_method_with_no_method (test_xmlrpc.TestXMLRPCIntegration) ... ok test_it (test_xmlrpc.TestXMLRPCIntegration) ... ok test_it_with_cls_view (test_xmlrpc.TestXMLRPCIntegration) ... ok test_it_with_default_args (test_xmlrpc.TestXMLRPCIntegration) ... ok test_it_with_general_exception (test_xmlrpc.TestXMLRPCIntegration) ... No handlers could be found for logger "pyramid_rpc.xmlrpc" ok test_it_with_invalid_body (test_xmlrpc.TestXMLRPCIntegration) ... ok test_it_with_invalid_method (test_xmlrpc.TestXMLRPCIntegration) ... ok test_it_with_missing_args (test_xmlrpc.TestXMLRPCIntegration) ... ok test_it_with_multiple_methods (test_xmlrpc.TestXMLRPCIntegration) ... ok test_it_with_no_mapper (test_xmlrpc.TestXMLRPCIntegration) ... ok test_it_with_no_method (test_xmlrpc.TestXMLRPCIntegration) ... ok test_it_with_no_params (test_xmlrpc.TestXMLRPCIntegration) ... ok test_it_with_too_many_args (test_xmlrpc.TestXMLRPCIntegration) ... ok test_method_decorator (test_xmlrpc.TestXMLRPCIntegration) ... ERROR test_method_decorator_with_method_from_view_name (test_xmlrpc.TestXMLRPCIntegration) ... ERROR test_method_decorator_with_no_endpoint (test_xmlrpc.TestXMLRPCIntegration) ... ok test_xmlrpc_marshal_fault (test_xmlrpc.TestXMLRPCMarshal) ... ok test_xmlrpc_marshal_normal (test_xmlrpc.TestXMLRPCMarshal) ... ok test_call_function (test_xmlrpc.TestXMLRPCViewDecorator) ... ok

ERROR: test_method_decorator (test_xmlrpc.TestXMLRPCIntegration)

Traceback (most recent call last): File "test_xmlrpc.py", line 368, in test_method_decorator resp = self._callFUT(app, 'create', (2, 3)) File "test_xmlrpc.py", line 169, in _callFUT return xmlrpclib.loads(resp.body)[0][0] File "/usr/lib/python2.7/xmlrpclib.py", line 1137, in loads return u.close(), u.getmethodname() File "/usr/lib/python2.7/xmlrpclib.py", line 793, in close raise Fault(**self._stack[0]) Fault: <Fault -32601: 'server error; requested method not found'>

ERROR: test_method_decorator_with_method_from_view_name (test_xmlrpc.TestXMLRPCIntegration)

Traceback (most recent call last): File "test_xmlrpc.py", line 378, in test_method_decorator_with_method_from_view_name resp = self._callFUT(app, 'create', (2, 3)) File "test_xmlrpc.py", line 169, in _callFUT return xmlrpclib.loads(resp.body)[0][0] File "/usr/lib/python2.7/xmlrpclib.py", line 1137, in loads return u.close(), u.getmethodname() File "/usr/lib/python2.7/xmlrpclib.py", line 793, in close raise Fault(**self._stack[0]) Fault: <Fault -32601: 'server error; requested method not found'>


Ran 24 tests in 0.164s

FAILED (errors=2)

nesiax commented 11 years ago

Hi guys, i have the same problem, config.scan don't work, i have to use config.add_xmlrpc_method(say_hello, endpoint='api', method='say_hello') in order for the server to handle xmlrpc request.

this is the code i have:

!/usr/bin/env python

from paste.httpserver import serve from pyramid.response import Response from pyramid.view import view_config

from pyramid_rpc.xmlrpc import xmlrpc_method

@xmlrpc_method(endpoint='api') def say_hello(request, name): return 'Hello, ' + name

if name == 'main': from pyramid.config import Configurator config = Configurator()

config.include('pyramid_rpc.xmlrpc')
config.add_xmlrpc_endpoint('api', '/api/xmlrpc')

#config.add_xmlrpc_method(say_hello, endpoint='api', method='say_hello')

config.scan()

app = config.make_wsgi_app()
serve(app, host='0.0.0.0')
nesiax commented 11 years ago

Hi guys, i have the same problem, config.scan don't work, i have to use config.add_xmlrpc_method(say_hello, endpoint='api', method='say_hello') in order for the server to handle xmlrpc request.

this is the code i have:

#!/usr/bin/env python

from paste.httpserver import serve
from pyramid.response import Response
from pyramid.view import view_config

from pyramid_rpc.xmlrpc import xmlrpc_method

@xmlrpc_method(endpoint='api')
def say_hello(request, name):
    return 'Hello, ' + name

if __name__ == '__main__':
    from pyramid.config import Configurator
    config = Configurator()

    config.include('pyramid_rpc.xmlrpc')
    config.add_xmlrpc_endpoint('api', '/api/xmlrpc')

    #
    #config.add_xmlrpc_method(say_hello, endpoint='api', method='say_hello')

    # scan
    config.scan()

    app = config.make_wsgi_app()
    serve(app, host='0.0.0.0')
cweimann commented 11 years ago

Downgrading venusian to 1.0a4 or lower will fix this problem. I'm guessing that the problem relates to the scanning related change introduced in 1.0a4 ( which is NOT broken with pyramid-rpc ) and 'improved' in 1.0a5 which breaks pyramid-rpc.

mmerickel commented 11 years ago

I'm, so far, unable to reproduce this. I'm using the test app pasted by @nesiax and testing with the following:

import xmlrpclib
proxy = xmlrpclib.ServerProxy('http://localhost:8080/api/xmlrpc')
proxy.say_hello('bob')

Can someone give me any more details? I'm on OS X mountain lion and the combinations I have tested so far are python 2.6 and python 2.7, pyramid 1.3.4 and pyramid 1.4a2, venusian 1.0a5 and venusian 1.0a7.

cweimann commented 11 years ago

This environment fails. % uname -mrs FreeBSD 8.3-RELEASE i386 % python -V Python 2.7.3 % workon broken (broken)% pip freeze Chameleon==2.10 Mako==0.7.2 MarkupSafe==0.15 Paste==1.7.5.1 PasteDeploy==1.5.0 PasteScript==1.7.5 WebOb==1.2.3 pyramid==1.2 pyramid-rpc==0.3 repoze.lru==0.6 translationstring==1.1 venusian==1.0a7 wsgiref==0.1.2 zope.component==4.0.0 zope.deprecation==4.0.0 zope.event==4.0.0 zope.interface==4.0.1

To fix this environment I just need to...

(broken)% pip install venusian==1.0a4

then rerun the server and all is well

mmerickel commented 11 years ago

I copied your pip freeze into a requirements.txt and installed it. Still no errors. I do not have a spare freebsd system lying around. Have you tried creating a new virtualenv? I ask because for some reason you have pyramid_rpc 0.3 installed when 0.3.1 was released almost a year ago.

cweimann commented 11 years ago

I built a new virtualenv and changed the test app from @nesiax to use wsgiref because paste is no longer a requirement for pyramid and I want to install as little as possible. It still fails. I have tried this on FreeBSD 6.2, 8.3, and 9.0. Two of those with python 2.7.2 and one with python 2.7.3. I need to see if I can find a linux box.

(rpc_test)% pip freeze Chameleon==2.10 Mako==0.7.2 MarkupSafe==0.15 PasteDeploy==1.5.0 WebOb==1.2.3 pyramid==1.4a3 pyramid-rpc==0.3.1 repoze.lru==0.6 translationstring==1.1 venusian==1.0a7 wsgiref==0.1.2 zope.deprecation==4.0.0 zope.interface==4.0.1

cweimann commented 11 years ago

I was able to reproduce the problem on an ubuntu machine and rolling back venusian does still fix it. Below is the freeze that fails.

(rpc_test)administrator@ubuntuVM:~$ uname -a Linux ubuntuVM 3.2.0-30-generic #48-Ubuntu SMP Fri Aug 24 16:54:40 UTC 2012 i686 i686 i386 GNU/Linux (rpc_test)administrator@ubuntuVM:~$ pip freeze Chameleon==2.10 Mako==0.7.2 MarkupSafe==0.15 PasteDeploy==1.5.0 WebOb==1.2.3 argparse==1.2.1 distribute==0.6.24 pyramid==1.4a3 pyramid-rpc==0.3.1 repoze.lru==0.6 translationstring==1.1 venusian==1.0a7 wsgiref==0.1.2 zope.deprecation==4.0.0 zope.interface==4.0.1 (rpc_test)administrator@ubuntuVM:~$

mmerickel commented 11 years ago

I managed to reproduce this on an ubuntu 12.04 VM. Looking into it.

mmerickel commented 11 years ago

After a deep dive into venusian I've diagnosed the issue. It's been unknowingly fixed in pyramid_rpc master for a long time. Basically venusian 1.0a5 broke the feature where a decorator was using view_config. In pyramid_rpc's master, it no longer wraps view_config and, instead, calls venusian itself.

@cweimann can you please confirm that the master branch works for you and I will cut a new release fixing this.

cweimann commented 11 years ago

Excellent. This is working.

(rpc_test)% pip freeze Chameleon==2.10 Mako==0.7.2 MarkupSafe==0.15 PasteDeploy==1.5.0 WebOb==1.2.3 pyramid==1.4a3 pyramid-rpc==0.4dev repoze.lru==0.6 translationstring==1.1 venusian==1.0a7 wsgiref==0.1.2 zope.deprecation==4.0.0 zope.interface==4.0.1

mmerickel commented 11 years ago

ok great, thanks for the help