The Client Application
In this example, any HTTP request made using a URL whose path falls under the base URL of "ht- tp://localhost:8000/service/", will be regarded as being a
The methods of the service which are available are the same as those which would be accessible over the service agent framework internal to your application. That is, a service must export a method for it to be accessible. The only such method available in this example would be "echo()".
The Client Application
Client side access to the
import netrpc
url = "http://localhost:8000/service/validator" service = netrpc.RemoteService(url)
print service.echo(1,1L,1.1,"1")
Only the "http" protocol is supported. If the URL specifies an unsupported protocol, the exception Ad- dressInvalid will be raised. If the URL didn’t identify a valid service on the remote host, a ServiceUnavailable exception is raised. Other possible exceptions which may be raised are AuthenticationFailure and TransportFailure. All the more specific exceptions actually derive from ServiceFailure and the ServiceFailure exception is also used for errors gen- erated by the service itself, so it is often sufficient to watch out for just that type of exception.
Restricting Client Access
In addition to being able to dictate precisely which services are visible, it is also possible to restrict access to specific clients. This can be done by allowing only certain hosts access, or by limiting access to specific individuals by using user authentication. Both schemes rely on features within the existing HTTP servlet framework.
class HttpDaemon(netsvc.HttpDaemon):
def __init__(self,port,hosts=["127.0.0.1"]): netsvc.HttpDaemon.__init__(self,port) self._allow = hosts
def authorise(self,host):