[Zope-Perl] more disruption
Monty Taylor
mtaylor@goldridge.net
Tue, 17 Oct 2000 12:01:05 +0200
Michel Pelletier wrote:
> Ok, I'm getting close to my goals, got everything running. Thanks
> Gisle.
>
> Follows is a section from the book, I'm wondering if someone can help me
> fill in the ???.
>
> Extra special bonus points go to anyone who can solve the Java one too.
> ;)
>
> -Michel
>
> Here's a fanciful example that shows you how to remotely script
> a mass firing of janitors using XML-RPC.
>
> Here's the code in Python::
>
> import xmlrpclib
>
> server = xmlrpclib.Server('http://www.zopezoo.org/')
> for employeeID in server.JanitorialDepartment.personnel():
> server.fireEmployee(employee)
>
> In Perl::
>
> use Frontier::Client;
>
> $server = Frontier::Client->new(url => $url);
> ???
>
> In Java::
>
> try
> {
> RPCClient rpc = new RPCClient();
> rpc.setServer("betty.userland.com");
> rpc.setPort(80);
> rpc.setProcedureName("JanitorialDepartment.personnel");
> Array employeeIds = (Array) rpc.executeRPC();
> }
> catch (RPCException ex)
> {
> ex.printStackTrace();
> }
>
> _______________________________________________
> Zope-perl maillist - Zope-perl@zope.org
> http://lists.zope.org/mailman/listinfo/zope-perl
Michael,
This should work, although this specific code is untested (I didn't feel
like making the zope methods -- but I tried the syntax with objectIds :) )
use Frontier::Client;
$server = Frontier::Client->new(url => "http://www.zopezoo.org/");
$employees = $server->call("JanitorialDepartment.personnel");
foreach $employee ( @$employees ) {
$server->call("fireEmployee",$server->string($employee));
}
Monty