from sfa.trust.certificate import *
from sfa.util.namespace import *
from sfa.util.sfalogging import *
-from sfa.server.registry import Registries
-from sfa.server.aggregate import Aggregates
# See "2.2 Characters" in the XML specification:
#
class BaseAPI:
- def __init__(self, config = "/etc/sfa/sfa_config.py", encoding = "utf-8", methods='sfa.methods',
-
- peer_cert = None, interface = None, key_file = None, cert_file = None):
+ cache = None
+
+ def __init__(self, config = "/etc/sfa/sfa_config.py", encoding = "utf-8",
+ methods='sfa.methods', peer_cert = None, interface = None,
+ key_file = None, cert_file = None, cache = cache):
self.encoding = encoding
# flat list of method names
-
self.methods_module = methods_module = __import__(methods, fromlist=[methods])
self.methods = methods_module.all
self.key = Keypair(filename=self.key_file)
self.cert_file = cert_file
self.cert = Certificate(filename=self.cert_file)
+ self.cache = cache
self.credential = None
self.source = None
self.time_format = "%Y-%m-%d %H:%M:%S"
self.logger=get_sfa_logger()
# load registries
+ from sfa.server.registry import Registries
self.registries = Registries(self)
# load aggregates
+ from sfa.server.aggregate import Aggregates
self.aggregates = Aggregates(self)
Return a new instance of the specified method.
"""
# Look up method
+ print self.methods
if method not in self.methods:
raise SfaInvalidAPIMethod, method
self.source = source
return function(*args)
- def handle(self, source, data):
+
+ def handle(self, source, data, method_map):
"""
Handle an XML-RPC or SOAP request from the specified source.
"""
try:
interface = xmlrpclib
(args, method) = xmlrpclib.loads(data)
+ if method_map.has_key(method):
+ method = method_map[method]
methodresponse = True
+
except Exception, e:
if SOAPpy is not None:
interface = SOAPpy