Critics have remarked that those four worthies were truly peerless throughout the ages; yet the present falls short of the pastβthe ancients favored unadorned simplicity, whereas the moderns prefer refined elegance. Styles of substance and ornament rise and fall in succession, shifting with the changing mores of the times; such evolution is simply the natural order of things. The ideal lies in honoring antiquity without clashing with the present, and embracing modernity without succumbing to its flawsβembodying that perfect balance of substance and refinement that defines the true gentleman. There is surely no need to abandon a carved palace in favor of a cave dwelling, or to trade a jade carriage for a primitive cart with solid wooden wheels.
Current path: lib64/python2.7/
β Cloned to:
β¬οΈ Go up: /lib64
οΏ½
zfc @ sοΏ½ d Z d d l Z d d l m Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z y d d l Z Wn e
k
rοΏ½ e Z n Xe d οΏ½ Z
d οΏ½ Z d οΏ½ Z d f d οΏ½ οΏ½ YZ d e j f d
οΏ½ οΏ½ YZ d e j e f d οΏ½ οΏ½ YZ d
e f d οΏ½ οΏ½ YZ d e f d οΏ½ οΏ½ YZ e d k rοΏ½d GHe d d f οΏ½ Z e j e οΏ½ e j d οΏ½ d οΏ½ e j οΏ½ e j οΏ½ n d S( s; Simple XML-RPC Server.
This module can be used to create simple XML-RPC servers
by creating a server and either installing functions, a
class instance, or by extending the SimpleXMLRPCServer
class.
It can also be used to handle XML-RPC requests in a CGI
environment using CGIXMLRPCRequestHandler.
A list of possible usage patterns follows:
1. Install functions:
server = SimpleXMLRPCServer(("localhost", 8000))
server.register_function(pow)
server.register_function(lambda x,y: x+y, 'add')
server.serve_forever()
2. Install an instance:
class MyFuncs:
def __init__(self):
# make all of the string functions available through
# string.func_name
import string
self.string = string
def _listMethods(self):
# implement this method so that system.listMethods
# knows to advertise the strings methods
return list_public_methods(self) + \
['string.' + method for method in list_public_methods(self.string)]
def pow(self, x, y): return pow(x, y)
def add(self, x, y) : return x + y
server = SimpleXMLRPCServer(("localhost", 8000))
server.register_introspection_functions()
server.register_instance(MyFuncs())
server.serve_forever()
3. Install an instance with custom dispatch method:
class Math:
def _listMethods(self):
# this method must be present for system.listMethods
# to work
return ['add', 'pow']
def _methodHelp(self, method):
# this method must be present for system.methodHelp
# to work
if method == 'add':
return "add(2,3) => 5"
elif method == 'pow':
return "pow(x, y[, z]) => number"
else:
# By convention, return empty
# string if no help is available
return ""
def _dispatch(self, method, params):
if method == 'pow':
return pow(*params)
elif method == 'add':
return params[0] + params[1]
else:
raise 'bad method'
server = SimpleXMLRPCServer(("localhost", 8000))
server.register_introspection_functions()
server.register_instance(Math())
server.serve_forever()
4. Subclass SimpleXMLRPCServer:
class MathServer(SimpleXMLRPCServer):
def _dispatch(self, method, params):
try:
# We are forcing the 'export_' prefix on methods that are
# callable through XML-RPC to prevent potential security
# problems
func = getattr(self, 'export_' + method)
except AttributeError:
raise Exception('method "%s" is not supported' % method)
else:
return func(*params)
def export_add(self, x, y):
return x + y
server = MathServer(("localhost", 8000))
server.serve_forever()
5. CGI script:
server = CGIXMLRPCRequestHandler()
server.register_function(pow)
server.handle_request()
iοΏ½οΏ½οΏ½οΏ½N( t Faultc C sg | r | j d οΏ½ } n | g } x? | D]7 } | j d οΏ½ rP t d | οΏ½ οΏ½ q( t | | οΏ½ } q( W| S( sG resolve_dotted_attribute(a, 'b.c.d') => a.b.c.d
Resolves a dotted attribute name to an object. Raises
an AttributeError if any attribute in the chain starts with a '_'.
If the optional allow_dotted_names argument is false, dots are not
supported and this function operates similar to getattr(obj, attr).
t .t _s( attempt to access private attribute "%s"( t splitt
startswitht AttributeErrort getattr( t objt attrt allow_dotted_namest attrst i( ( s* /usr/lib64/python2.7/SimpleXMLRPCServer.pyt resolve_dotted_attributes s
c C sE g t | οΏ½ D]4 } | j d οΏ½ r
t t | | οΏ½ d οΏ½ r
| ^ q
S( sk Returns a list of attribute strings, found in the specified
object, which represent callable attributesR t __call__( t dirR t hasattrR ( R t member( ( s* /usr/lib64/python2.7/SimpleXMLRPCServer.pyt list_public_methodsοΏ½ s c C s+ i } x | D] } d | | <q
W| j οΏ½ S( sοΏ½ remove_duplicates([2,2,2,1,3,3]) => [3,1,2]
Returns a copy of a list without duplicates. Every list
item must be hashable and the order of the items in the
resulting list is not defined.
i ( t keys( t lstt ut x( ( s* /usr/lib64/python2.7/SimpleXMLRPCServer.pyt remove_duplicatesοΏ½ s
t SimpleXMLRPCDispatcherc B sοΏ½ e Z d Z e d d οΏ½ Z e d οΏ½ Z d d οΏ½ Z d οΏ½ Z d οΏ½ Z d d d οΏ½ Z
d οΏ½ Z d οΏ½ Z d οΏ½ Z
d
οΏ½ Z d οΏ½ Z RS(
s' Mix-in class that dispatches XML-RPC requests.
This class is used to register XML-RPC method handlers
and then to dispatch them. This class doesn't need to be
instanced directly when used by SimpleXMLRPCServer but it
can be instanced when used by the MultiPathXMLRPCServer.
c C s( i | _ d | _ | | _ | | _ d S( N( t funcst Nonet instancet
allow_nonet encoding( t selfR R ( ( s* /usr/lib64/python2.7/SimpleXMLRPCServer.pyt __init__οΏ½ s c C s | | _ | | _ d S( s Registers an instance to respond to XML-RPC requests.
Only one instance can be installed at a time.
If the registered instance has a _dispatch method then that
method will be called with the name of the XML-RPC method and
its parameters as a tuple
e.g. instance._dispatch('add',(2,3))
If the registered instance does not have a _dispatch method
then the instance will be searched to find a matching method
and, if found, will be called. Methods beginning with an '_'
are considered private and will not be called by
SimpleXMLRPCServer.
If a registered function matches an XML-RPC request, then it
will be called instead of the registered instance.
If the optional allow_dotted_names argument is true and the
instance does not have a _dispatch method, method names
containing dots are supported and resolved, as long as none of
the name segments start with an '_'.
*** SECURITY WARNING: ***
Enabling the allow_dotted_names options allows intruders
to access your module's global variables and may allow
intruders to execute arbitrary code on your machine. Only
use this option on a secure, closed network.
N( R R ( R R R ( ( s* /usr/lib64/python2.7/SimpleXMLRPCServer.pyt register_instanceοΏ½ s ! c C s) | d k r | j } n | | j | <d S( sοΏ½ Registers a function to respond to XML-RPC requests.
The optional name argument can be used to set a Unicode name
for the function.
N( R t __name__R ( R t functiont name( ( s* /usr/lib64/python2.7/SimpleXMLRPCServer.pyt register_functionοΏ½ s c C s2 | j j i | j d 6| j d 6| j d 6οΏ½ d S( sοΏ½ Registers the XML-RPC introspection methods in the system
namespace.
see http://xmlrpc.usefulinc.com/doc/reserved.html
s system.listMethodss system.methodSignatures system.methodHelpN( R t updatet system_listMethodst system_methodSignaturet system_methodHelp( R ( ( s* /usr/lib64/python2.7/SimpleXMLRPCServer.pyt register_introspection_functionsοΏ½ s
c C s | j j i | j d 6οΏ½ d S( sοΏ½ Registers the XML-RPC multicall method in the system
namespace.
see http://www.xmlrpc.com/discuss/msgReader$1208s system.multicallN( R R$ t system_multicall( R ( ( s* /usr/lib64/python2.7/SimpleXMLRPCServer.pyt register_multicall_functionsοΏ½ s c C s yy t j | οΏ½ \ } } | d k r6 | | | οΏ½ } n | j | | οΏ½ } | f } t j | d d d | j d | j οΏ½} WnοΏ½ t k
rοΏ½ } t j | d | j d | j οΏ½} nS t j οΏ½ \ } } }
t j t j d d | | f οΏ½ d | j d | j οΏ½} n X| S( sοΏ½ Dispatches an XML-RPC method from marshalled (XML) data.
XML-RPC methods are dispatched from the marshalled (XML) data
using the _dispatch method and the result is returned as
marshalled data. For backwards compatibility, a dispatch
function can be provided as an argument (see comment in
SimpleXMLRPCRequestHandler.do_POST) but overriding the
existing method through subclassing is the preferred means
of changing method dispatch behavior.
t methodresponsei R R s %s:%sN(
t xmlrpclibt loadsR t _dispatcht dumpsR R R t syst exc_info( R t datat dispatch_methodt patht paramst methodt responset faultt exc_typet exc_valuet exc_tb( ( s* /usr/lib64/python2.7/SimpleXMLRPCServer.pyt _marshaled_dispatchοΏ½ s"