$ cat server.py
from configit import conf_from_file
config = conf_from_file('../development.py')
from BridgePython import Bridge
class SimpleHandler(object):
def simple(self, simple=None, callback=None):
if simple and callback:
callback('Simple is {0}'.format(simple))
elif callback:
callback('Simple not passed')
bridge = Bridge(api_key=config.private_api_key)
bridge.publish_service('simple', SimpleHandler())
bridge.connect()
$ cat client.py
from configit import conf_from_file
config = conf_from_file('../development.py')
from BridgePython import Bridge
bridge = Bridge(api_key=config.public_api_key)
client = None
def service_response(resp):
print(resp)
service = bridge.get_service('simple')
try:
service.simple(simple='simple text', callback=service_response)
except TypeError as e:
print(e)
service.simple('simple text', service_response)
bridge.connect()
Results:
$ python client.py
<lambda>() got an unexpected keyword argument 'simple'
Simple is simple text
--
You received this message because you are subscribed to the Google Groups "Bridge" group.
To post to this group, send email to bridge...@googlegroups.com.
To unsubscribe from this group, send email to bridge-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/bridge-users/-/dKuBYdpBM7MJ.
For more options, visit https://groups.google.com/groups/opt_out.
Not at the moment. It would be hard to map the concept of keyword arguments to any of the other languages we support (except maybe Ruby).Are you using Bridge for primarily Python to Python communication?
--Sridatta
To unsubscribe from this group, send email to bridge-users+unsubscribe@googlegroups.com.
Hmm, looked into using both kwargs and args simultaneously. For the
two wrapper services, try:
class RemoteService():
def __init__(self, svc):
self.svc = svc
def __getattr__(self, attr):
if getattr(self.svc, attr):
return lambda *args, **kwargs: getattr(self.svc,
attr)(*(args + (kwargs,)))
raise AttributeError(attr)
class WrappedService():
def __init__(self, svc):
self.svc = svc
def __getattr__(self, attr):
if getattr(self.svc, attr):
return lambda *args: getattr(self.svc, attr)(*args[:-1], **args[-1])
raise AttributeError(attr)