mirror of https://github.com/python/cpython.git
Two fixes in DocXMLRPCServer:
* remove parameter default that didn't make sense * properly escape values in output Thanks to Jeff Wheeler from GHOP!
This commit is contained in:
parent
b0885b7278
commit
6113ce51b3
|
@ -64,14 +64,15 @@ def markup(self, text, escape=None, funcs={}, classes={}, methods={}):
|
||||||
results.append(escape(text[here:]))
|
results.append(escape(text[here:]))
|
||||||
return ''.join(results)
|
return ''.join(results)
|
||||||
|
|
||||||
def docroutine(self, object, name=None, mod=None,
|
def docroutine(self, object, name, mod=None,
|
||||||
funcs={}, classes={}, methods={}, cl=None):
|
funcs={}, classes={}, methods={}, cl=None):
|
||||||
"""Produce HTML documentation for a function or method object."""
|
"""Produce HTML documentation for a function or method object."""
|
||||||
|
|
||||||
anchor = (cl and cl.__name__ or '') + '-' + name
|
anchor = (cl and cl.__name__ or '') + '-' + name
|
||||||
note = ''
|
note = ''
|
||||||
|
|
||||||
title = '<a name="%s"><strong>%s</strong></a>' % (anchor, name)
|
title = '<a name="%s"><strong>%s</strong></a>' % (
|
||||||
|
self.escape(anchor), self.escape(name))
|
||||||
|
|
||||||
if inspect.ismethod(object):
|
if inspect.ismethod(object):
|
||||||
args, varargs, varkw, defaults = inspect.getargspec(object.im_func)
|
args, varargs, varkw, defaults = inspect.getargspec(object.im_func)
|
||||||
|
@ -113,6 +114,7 @@ def docserver(self, server_name, package_documentation, methods):
|
||||||
fdict[key] = '#-' + key
|
fdict[key] = '#-' + key
|
||||||
fdict[value] = fdict[key]
|
fdict[value] = fdict[key]
|
||||||
|
|
||||||
|
server_name = self.escape(server_name)
|
||||||
head = '<big><big><strong>%s</strong></big></big>' % server_name
|
head = '<big><big><strong>%s</strong></big></big>' % server_name
|
||||||
result = self.heading(head, '#ffffff', '#7799ee')
|
result = self.heading(head, '#ffffff', '#7799ee')
|
||||||
|
|
||||||
|
@ -280,29 +282,3 @@ def handle_get(self):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
CGIXMLRPCRequestHandler.__init__(self)
|
CGIXMLRPCRequestHandler.__init__(self)
|
||||||
XMLRPCDocGenerator.__init__(self)
|
XMLRPCDocGenerator.__init__(self)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
def deg_to_rad(deg):
|
|
||||||
"""deg_to_rad(90) => 1.5707963267948966
|
|
||||||
|
|
||||||
Converts an angle in degrees to an angle in radians"""
|
|
||||||
import math
|
|
||||||
return deg * math.pi / 180
|
|
||||||
|
|
||||||
server = DocXMLRPCServer(("localhost", 8000))
|
|
||||||
|
|
||||||
server.set_server_title("Math Server")
|
|
||||||
server.set_server_name("Math XML-RPC Server")
|
|
||||||
server.set_server_documentation("""This server supports various mathematical functions.
|
|
||||||
|
|
||||||
You can use it from Python as follows:
|
|
||||||
|
|
||||||
>>> from xmlrpclib import ServerProxy
|
|
||||||
>>> s = ServerProxy("http://localhost:8000")
|
|
||||||
>>> s.deg_to_rad(90.0)
|
|
||||||
1.5707963267948966""")
|
|
||||||
|
|
||||||
server.register_function(deg_to_rad)
|
|
||||||
server.register_introspection_functions()
|
|
||||||
|
|
||||||
server.serve_forever()
|
|
||||||
|
|
Loading…
Reference in New Issue