def start_request(self, call_list): """ Setup the database, then pass the call list on to dispatch_many to handle them. """ db.begin_txn() try: results = self.dispatch_many(call_list) except Fault, fault: db.abort_txn() log.warning("Fault %d: %s" %(fault.faultCode, fault.faultString)) raise
def start_request(self, call_list): """ Setup the database, then pass the call list on to dispatch_many to handle them. """ db.begin_txn() try: results = self.dispatch_many(call_list) except Fault, fault: db.abort_txn() log.warning("Fault %d: %s" % (fault.faultCode, fault.faultString)) raise
class RequestDispatcher(SimpleXMLRPCDispatcher): """ This is the class will be instantiated on each request. The first argument will be the path being requested. The _dispatch method will then be called with the function name and arguments list. >>> class TestDispatcher(RequestDispatcher): ... instance_class = ExampleRPCFunctions ... >>> d = TestDispatcher("/foo/") >>> d._dispatch('add', (40, 2)) 42 >>> d._dispatch('path', []) u'/foo/' >>> """ instance_class = OntologyTool def __init__(self, path): path = to_unicode(path) SimpleXMLRPCDispatcher.__init__(self, True, 'utf-8') self.register_introspection_functions() self.register_multicall_functions() self.instance = self.instance_class(path) self.path = path # Ideally, the control loop will look like this: # start_database_transaction() # for function_call in function_calls: # function_call() # finish_database_transaction() # Unfortunatly SimpleXMLRPCDispatcher makes that a little tricky. # Please forgive the small amount of duplicated coded here. def start_request(self, call_list): """ Setup the database, then pass the call list on to dispatch_many to handle them. """ db.begin_txn() try: results = self.dispatch_many(call_list) except Fault, fault: db.abort_txn() log.warning("Fault %d: %s" % (fault.faultCode, fault.faultString)) raise except Exception, e: db.abort_txn() log.exception(e) raise
def teardown(self): db.abort_txn()