[Zope] XML-RPC woes

Evan Simpson evan@digicool.com
Fri, 11 Feb 2000 09:35:24 -0600


----- Original Message -----
From: Tony McDonald <tony.mcdonald@ncl.ac.uk>
> server_url="http://xmlrpc.server:9999"
> server=xmlrpclib.Server(server_url)
> server.getTranscript(number)

Is this the whole text?  You never return anything, so the caller gets
'None' back.  (Don't worry, I've done that myself a few times)

> If I make the PythonMethod be;
> import xmlrpclib
>
> def doit(number):
>      server_url="http://xmlrpc.server:9999"
>      server=xmlrpclib.Server(server_url)
>      return server.getTranscript(number)
>
> doit(number)

You can't treat PythonMethods like modules.  In a module, the 'import' would
put 'xmlrpclib' into the module-global namespace, where 'doit' could find
it.  In this PM, 'import' creates a local variable which is not visible from
'doit'.  Unless it really helps reduce redundancy, functions in PMs aren't
generally a good idea.  You could make this example work by adding a 'global
xmlrpclib' line before the 'import' line, though.

Cheers,

Evan @ digicool