私はcherrypyサーバーを使用して、PythonクライアントからpyAMFチャネルを介してリクエストを受信しています。以下のモックアップから始めましたが、正常に機能します。
サーバ:
import cherrypy
from pyamf.remoting.gateway.wsgi import WSGIGateway
def echo(*args, **kwargs):
return (args, kwargs)
class Root(object):
def index(self):
return "running"
index.exposed = True
services = {
'myService.echo': echo,
}
gateway = WSGIGateway(services, debug=True)
cherrypy.tree.graft(gateway, "/gateway/")
cherrypy.quickstart(Root())
クライアント:
from pyamf.remoting.client import RemotingService
path = 'http://localhost:8080/gateway/'
gw = RemotingService(path)
service = gw.getService('myService')
print service.echo('one=1, two=3')
結果: [[u'one = 1、two = 3']、{}]
代わりに今なら:
def echo(*args, **kwargs):
return (args, kwargs)
私が使う:
def echo(**kwargs):
return kwargs
同じリクエストを送信すると、次のエラーが発生します。
TypeError:echo()は正確に0個の引数を取ります(1個指定)
同時に:
>>> def f(**kwargs): return kwargs
...
>>> f(one=1, two=3)
{'two': 3, 'one': 1}
>>>
質問:なぜこれが起こっているのですか?洞察を共有してください
私が使用しているもの:python 2.5.2、cherrypy 3.1.2、pyamf 0.5.1