d8966b59b6
work around the limitations of the security-patched SimpleXMLRPCServer
50 lines
1.9 KiB
Text
50 lines
1.9 KiB
Text
$NetBSD: patch-aa,v 1.1 2005/02/04 17:24:16 drochner Exp $
|
|
|
|
--- kenosis/node.py.orig 2005-02-04 17:40:36.000000000 +0100
|
|
+++ kenosis/node.py
|
|
@@ -309,7 +309,8 @@ class NullHandler:
|
|
class NodeRpcFrontend:
|
|
def __init__(self, nodeKernel):
|
|
self.nodeKernel_ = nodeKernel
|
|
- self.kenosis = RpcServerAdapter(
|
|
+ self.services = {}
|
|
+ self.services["kenosis"] = RpcServerAdapter(
|
|
adaptee=NodeRpcFilter(nodeKernel=nodeKernel),
|
|
nodeKernel=self.nodeKernel_, serviceName="kenosis")
|
|
|
|
@@ -319,22 +320,28 @@ class NodeRpcFrontend:
|
|
def registerNamedHandler(self, name, handler):
|
|
if nameIsPrivate(name=name):
|
|
raise Exception("invalid handler: %s" % name)
|
|
- setattr(
|
|
- self, name,
|
|
- RpcServerAdapter(adaptee=handler, nodeKernel=self.nodeKernel_, serviceName=name))
|
|
+ self.services[name] = \
|
|
+ RpcServerAdapter(adaptee=handler, nodeKernel=self.nodeKernel_, serviceName=name)
|
|
+
|
|
+ def _dispatch(self, name, args):
|
|
+ (sname, rest) = name.split('.', 1)
|
|
+ fn = SimpleXMLRPCServer.resolve_dotted_attribute(
|
|
+ self.services[sname], rest)
|
|
+ return fn(*args)
|
|
+
|
|
|
|
def _listMethods(self):
|
|
ret = []
|
|
- for attrName in dir(self):
|
|
- attr = getattr(self, attrName)
|
|
+ for attrName in keys(self.services):
|
|
+ attr = self.services[attrName]
|
|
if isinstance(attr, RpcServerAdapter):
|
|
for methodName in attr._listPublicMethod():
|
|
ret.append("%s.%s" % (attrName, methodName))
|
|
return ret
|
|
|
|
def _methodHelp(self, method):
|
|
- for attrName in dir(self):
|
|
- attr = getattr(self, attrName)
|
|
+ for attrName in keys(self.services):
|
|
+ attr = self.services[attrName]
|
|
if isinstance(attr, RpcServerAdapter):
|
|
for methodName in attr._listPublicMethod():
|
|
n = "%s.%s" % (attrName, methodName)
|