Simple CGI-XMLRPC failure

M

Mike MacHenry

I am having a difficult time understanding why my very simple
CGI-XMLRPC test isn't working. I created a server to export two
functions, the built-in function "pow" and my own identity function
"i". I run a script to call both of them and the "pow" work fine but
the "i" gives me an error that says my XMLRPC server doesn't support
than name. Here is the code for both files and the output:

#!/usr/bin/env python
#This file is /usr/lib/cgi-bin/roundwarerpc.py
from SimpleXMLRPCServer import CGIXMLRPCRequestHandler
def i(x):
return x
server = CGIXMLRPCRequestHandler()
server.register_function(pow)
server.register_function(i)
server.handle_request()


#!/usr/bin/env python
#This file is ~/test.py
import xmlrpclib
server = xmlrpclib.ServerProxy("http://localhost/cgi-bin/roundwarerpc.py")
print server.pow(2,3)
print server.i(10)

#This is the STDOUT and STDERR when running ~/test.py
dskippy@dskippy-laptop:$ python test.py 8
Traceback (most recent call last):
File "test.py", line 4, in <module>
print server.test(10)
File "/usr/lib/python2.5/xmlrpclib.py", line 1147, in __call__
return self.__send(self.__name, args)
File "/usr/lib/python2.5/xmlrpclib.py", line 1437, in __request
verbose=self.__verbose
File "/usr/lib/python2.5/xmlrpclib.py", line 1201, in request
return self._parse_response(h.getfile(), sock)
File "/usr/lib/python2.5/xmlrpclib.py", line 1340, in _parse_response
return u.close()
File "/usr/lib/python2.5/xmlrpclib.py", line 787, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: '<type \'exceptions.Exception\'>:method "i"
is not supported'>

Does anyone know what might be wrong with this?

Thanks for the help,
-mike

p.s.
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Server version Apache/2.2.8 (Ubuntu)
Server built: Jun 25 2008 13:54:13
 
D

Diez B. Roggisch

Mike said:
I am having a difficult time understanding why my very simple
CGI-XMLRPC test isn't working. I created a server to export two
functions, the built-in function "pow" and my own identity function
"i". I run a script to call both of them and the "pow" work fine but
the "i" gives me an error that says my XMLRPC server doesn't support
than name. Here is the code for both files and the output:

#!/usr/bin/env python
#This file is /usr/lib/cgi-bin/roundwarerpc.py
from SimpleXMLRPCServer import CGIXMLRPCRequestHandler
def i(x):
return x
server = CGIXMLRPCRequestHandler()
server.register_function(pow)
server.register_function(i)
server.handle_request()


#!/usr/bin/env python
#This file is ~/test.py
import xmlrpclib
server = xmlrpclib.ServerProxy("http://localhost/cgi-bin/roundwarerpc.py")
print server.pow(2,3)
print server.i(10)

#This is the STDOUT and STDERR when running ~/test.py
dskippy@dskippy-laptop:$ python test.py 8
Traceback (most recent call last):
File "test.py", line 4, in <module>
print server.test(10)
File "/usr/lib/python2.5/xmlrpclib.py", line 1147, in __call__
return self.__send(self.__name, args)
File "/usr/lib/python2.5/xmlrpclib.py", line 1437, in __request
verbose=self.__verbose
File "/usr/lib/python2.5/xmlrpclib.py", line 1201, in request
return self._parse_response(h.getfile(), sock)
File "/usr/lib/python2.5/xmlrpclib.py", line 1340, in _parse_response
return u.close()
File "/usr/lib/python2.5/xmlrpclib.py", line 787, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: '<type \'exceptions.Exception\'>:method "i"
is not supported'>

Does anyone know what might be wrong with this?

This works.

---
import threading


from SimpleXMLRPCServer import SimpleXMLRPCServer

def i(x):
return x

server = SimpleXMLRPCServer(('localhost', 10000))
server.register_function(pow)
server.register_function(i)
t = threading.Thread(target=server.serve_forever)
t.setDaemon(True)
t.start()

import xmlrpclib
server = xmlrpclib.ServerProxy("http://localhost:10000")
print server.pow(2,3)
print server.i(10)
---

So maybe i is somehow an instance-variable of CGIXMLRPCRequestHandler.
What happens if you rename it?

Diez
 
J

Jeff McNeil

I am having a difficult time understanding why my very simple
CGI-XMLRPC test isn't working. I created a server to export two
functions, the built-in function "pow" and my own identity function
"i". I run a script to call both of them and the "pow" work fine but
the "i" gives me an error that says my XMLRPC server doesn't support
than name. Here is the code for both files and the output:

#!/usr/bin/env python
#This file is /usr/lib/cgi-bin/roundwarerpc.py
from SimpleXMLRPCServer import CGIXMLRPCRequestHandler
def i(x):
        return x
server = CGIXMLRPCRequestHandler()
server.register_function(pow)
server.register_function(i)
server.handle_request()

#!/usr/bin/env python
#This file is ~/test.py
import xmlrpclib
server = xmlrpclib.ServerProxy("http://localhost/cgi-bin/roundwarerpc.py")
print server.pow(2,3)
print server.i(10)

#This is the STDOUT and STDERR when running ~/test.py
dskippy@dskippy-laptop:$ python test.py 8
Traceback (most recent call last):
  File "test.py", line 4, in <module>
    print server.test(10)
  File "/usr/lib/python2.5/xmlrpclib.py", line 1147, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.5/xmlrpclib.py", line 1437, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.5/xmlrpclib.py", line 1201, in request
    return self._parse_response(h.getfile(), sock)
  File "/usr/lib/python2.5/xmlrpclib.py", line 1340, in _parse_response
    return u.close()
  File "/usr/lib/python2.5/xmlrpclib.py", line 787, in close
    raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: '<type \'exceptions.Exception\'>:method "i"
is not supported'>

Does anyone know what might be wrong with this?

Thanks for the help,
-mike

p.s.
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Server version Apache/2.2.8 (Ubuntu)
Server built: Jun 25 2008 13:54:13

I copied your code verbatim and I don't have any issues with it at
all. Same version of Python, same version of Apache.

In SimpleXMLRPCServer.py, register_function adds directly to a
self.funcs dictionary, so an instance variable of the same name
shouldn't hurt anything. That exception is only raised when a
self.funcs lookup raises a KeyError unless you're registering an
instance.
 
M

Mike MacHenry

I figured it was some kind of bug. Must be either a bug with my
version of either the library (most likely) or perhaps some weird
environment setting that I have set incorrectly (also likely). How can
I figure out which version of SimpleXMLRPCServer I'm running? Do you
run Ubuntu by any chance? If you which version?

Does anyone know of any environment settings I could look into on
Apache or Python?

-mike

I am having a difficult time understanding why my very simple
CGI-XMLRPC test isn't working. I created a server to export two
functions, the built-in function "pow" and my own identity function
"i". I run a script to call both of them and the "pow" work fine but
the "i" gives me an error that says my XMLRPC server doesn't support
than name. Here is the code for both files and the output:

#!/usr/bin/env python
#This file is /usr/lib/cgi-bin/roundwarerpc.py
from SimpleXMLRPCServer import CGIXMLRPCRequestHandler
def i(x):
return x
server = CGIXMLRPCRequestHandler()
server.register_function(pow)
server.register_function(i)
server.handle_request()

#!/usr/bin/env python
#This file is ~/test.py
import xmlrpclib
server = xmlrpclib.ServerProxy("http://localhost/cgi-bin/roundwarerpc.py")
print server.pow(2,3)
print server.i(10)

#This is the STDOUT and STDERR when running ~/test.py
dskippy@dskippy-laptop:$ python test.py 8
Traceback (most recent call last):
File "test.py", line 4, in <module>
print server.test(10)
File "/usr/lib/python2.5/xmlrpclib.py", line 1147, in __call__
return self.__send(self.__name, args)
File "/usr/lib/python2.5/xmlrpclib.py", line 1437, in __request
verbose=self.__verbose
File "/usr/lib/python2.5/xmlrpclib.py", line 1201, in request
return self._parse_response(h.getfile(), sock)
File "/usr/lib/python2.5/xmlrpclib.py", line 1340, in _parse_response
return u.close()
File "/usr/lib/python2.5/xmlrpclib.py", line 787, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: '<type \'exceptions.Exception\'>:method "i"
is not supported'>

Does anyone know what might be wrong with this?

Thanks for the help,
-mike

p.s.
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Server version Apache/2.2.8 (Ubuntu)
Server built: Jun 25 2008 13:54:13

I copied your code verbatim and I don't have any issues with it at
all. Same version of Python, same version of Apache.

In SimpleXMLRPCServer.py, register_function adds directly to a
self.funcs dictionary, so an instance variable of the same name
shouldn't hurt anything. That exception is only raised when a
self.funcs lookup raises a KeyError unless you're registering an
instance.
 
J

Jeff McNeil

I don't have the version in front of me now as that was on my home
machine, but Python was the same right down to the revision number.
Unless you've mucked with it, it's the same file that I've got on my
box.

Jeff

I figured it was some kind of bug. Must be either a bug with my
version of either the library (most likely) or perhaps some weird
environment setting that I have set incorrectly (also likely). How can
I figure out which version of SimpleXMLRPCServer I'm running? Do you
run Ubuntu by any chance? If you which version?

Does anyone know of any environment settings I could look into on
Apache or Python?

-mike

I am having a difficult time understanding why my very simple
CGI-XMLRPC test isn't working. I created a server to export two
functions, the built-in function "pow" and my own identity function
"i". I run a script to call both of them and the "pow" work fine but
the "i" gives me an error that says my XMLRPC server doesn't support
than name. Here is the code for both files and the output:
#!/usr/bin/env python
#This file is /usr/lib/cgi-bin/roundwarerpc.py
from SimpleXMLRPCServer import CGIXMLRPCRequestHandler
def i(x):
return x
server = CGIXMLRPCRequestHandler()
server.register_function(pow)
server.register_function(i)
server.handle_request()
#!/usr/bin/env python
#This file is ~/test.py
import xmlrpclib
server = xmlrpclib.ServerProxy("http://localhost/cgi-bin/roundwarerpc.py")
print server.pow(2,3)
print server.i(10)
#This is the STDOUT and STDERR when running ~/test.py
dskippy@dskippy-laptop:$ python test.py 8
Traceback (most recent call last):
File "test.py", line 4, in <module>
print server.test(10)
File "/usr/lib/python2.5/xmlrpclib.py", line 1147, in __call__
return self.__send(self.__name, args)
File "/usr/lib/python2.5/xmlrpclib.py", line 1437, in __request
verbose=self.__verbose
File "/usr/lib/python2.5/xmlrpclib.py", line 1201, in request
return self._parse_response(h.getfile(), sock)
File "/usr/lib/python2.5/xmlrpclib.py", line 1340, in _parse_response
return u.close()
File "/usr/lib/python2.5/xmlrpclib.py", line 787, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: '<type \'exceptions.Exception\'>:method "i"
is not supported'>
Does anyone know what might be wrong with this?
Thanks for the help,
-mike
p.s.
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Server version Apache/2.2.8 (Ubuntu)
Server built: Jun 25 2008 13:54:13
I copied your code verbatim and I don't have any issues with it at
all. Same version of Python, same version of Apache.
In SimpleXMLRPCServer.py, register_function adds directly to a
self.funcs dictionary, so an instance variable of the same name
shouldn't hurt anything. That exception is only raised when a
self.funcs lookup raises a KeyError unless you're registering an
instance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top