Remote Access
Even if a new protocol comes along, it is a relatively simple matter to incorporate yet another gateway, again without you having to make modifications to the core of your system.
The RPC Gateway
The gateway which accepts an RPC request is actually an instance of a HTTP server object. The gate- way will accept a request and based on the URL determine which service the request applies to. The request will then be translated into a call over the service agent framework, with the corresponding re- sult being packaged up and returned to the remote client.
Because the service agent framework can operate in a distributed manner using the message exchange framework, the service which a request applies to need not even be in the same process as the RPC gateway. So that a remote client can’t access any arbitrary service however, a mechanism is provided to limit which services are actually visible. The mechanisms for client and user authorisation imple- mented by the HTTP servlet framework can also be used to block access as appropriate.
For the
import netsvc import signal
class Validator(netsvc.Service):
def __init__(self,name="validator"): netsvc.Service.__init__(self,name)
def echo(self,*args) return args
dispatcher = netsvc.Dispatcher() dispatcher.monitor(signal.SIGINT)
validator = Validator()
port = 8000
group =
httpd = netsvc.HttpDaemon(port) rpcgw = netsvc.RpcGateway(group) httpd.attach("/service",rpcgw) httpd.start()
dispatcher.run()
112