aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authortemporal <temporal@630680e5-0e50-0410-840e-4b1c322b438d>2008-07-18 16:35:38 +0000
committertemporal <temporal@630680e5-0e50-0410-840e-4b1c322b438d>2008-07-18 16:35:38 +0000
commit1bd04af06cfbe7f64bb5fd8ee9073d749c57607b (patch)
tree445cb9065601ba2d50cfc5a01cfab727fbf664a8 /python
parent0919b3fc8e13884c66168924e62cb3679a20a734 (diff)
downloadprotobuf-1bd04af06cfbe7f64bb5fd8ee9073d749c57607b.tar.gz
Fix Python service CallMethod() implementation.
Patch from Johan Euphrosine <proppy@aminche.com> git-svn-id: http://protobuf.googlecode.com/svn/trunk@13 630680e5-0e50-0410-840e-4b1c322b438d
Diffstat (limited to 'python')
-rwxr-xr-xpython/google/protobuf/internal/service_reflection_test.py18
-rwxr-xr-xpython/google/protobuf/service_reflection.py4
2 files changed, 20 insertions, 2 deletions
diff --git a/python/google/protobuf/internal/service_reflection_test.py b/python/google/protobuf/internal/service_reflection_test.py
index 895d24d..d43ed64 100755
--- a/python/google/protobuf/internal/service_reflection_test.py
+++ b/python/google/protobuf/internal/service_reflection_test.py
@@ -64,6 +64,24 @@ class FooUnitTest(unittest.TestCase):
self.assertEqual('Method Bar not implemented.',
rpc_controller.failure_message)
self.assertEqual(None, self.callback_response)
+
+ class MyServiceImpl(unittest_pb2.TestService):
+ def Foo(self, rpc_controller, request, done):
+ self.foo_called = True
+ def Bar(self, rpc_controller, request, done):
+ self.bar_called = True
+
+ srvc = MyServiceImpl()
+ rpc_controller.failure_message = None
+ srvc.Foo(rpc_controller, unittest_pb2.FooRequest(), MyCallback)
+ self.assertEqual(None, rpc_controller.failure_message)
+ self.assertEqual(True, srvc.foo_called)
+
+ rpc_controller.failure_message = None
+ srvc.CallMethod(service_descriptor.methods[1], rpc_controller,
+ unittest_pb2.BarRequest(), MyCallback)
+ self.assertEqual(None, rpc_controller.failure_message)
+ self.assertEqual(True, srvc.bar_called)
def testServiceStub(self):
class MockRpcChannel(service.RpcChannel):
diff --git a/python/google/protobuf/service_reflection.py b/python/google/protobuf/service_reflection.py
index 6e3bf14..6439eaa 100755
--- a/python/google/protobuf/service_reflection.py
+++ b/python/google/protobuf/service_reflection.py
@@ -160,8 +160,8 @@ class _ServiceBuilder(object):
if method_descriptor.containing_service != self.descriptor:
raise RuntimeError(
'CallMethod() given method descriptor for wrong service type.')
- method = getattr(self.cls, method_descriptor.name)
- method(srvc, rpc_controller, request, callback)
+ method = getattr(srvc, method_descriptor.name)
+ method(rpc_controller, request, callback)
def _GetRequestClass(self, method_descriptor):
"""Returns the class of the request protocol message.