class Application(AppBase): def __init__(self, services, tns, name=None, in_protocol=None, out_protocol=None, db=None): AppBase.__init__(self, services, tns, name, in_protocol, out_protocol) self.event_manager.add_listener("method_call", _on_method_call) self.event_manager.add_listener("method_context_closed", _on_method_context_closed) self.db = db self.Session = sessionmaker(bind=db, expire_on_commit=False) def call_wrapper(self, ctx): try: return ctx.service_class.call_wrapper(ctx) except NoResultFound: raise ResourceNotFoundError(ctx.in_object) except Fault, e: log.err() raise except Exception, e: log.err() # This should not happen! Let the team know via email! if EXCEPTION_ADDRESS: email_exception(EXCEPTION_ADDRESS) raise InternalError(e)
class MyApplication(Application): def __init__(self, services, tns, name=None, in_protocol=None, out_protocol=None): super(MyApplication, self).__init__(services, tns, name, in_protocol, out_protocol) self.event_manager.add_listener('method_call', _on_method_call) self.event_manager.add_listener("method_context_closed", _on_method_context_closed) def call_wrapper(self, ctx): try: return ctx.service_class.call_wrapper(ctx) except NoResultFound: raise ResourceNotFoundError(ctx.in_object) except Fault, e: logger.error(e) raise except Exception, e: logger.exception(e) # This should not happen! Let the team know via email email_exception(EXCEPTION_ADDRESS) raise InternalError(e)
def call_wrapper(self, ctx): try: return ctx.service_class.call_wrapper(ctx) except NoResultFound: raise ResourceNotFoundError(ctx.in_object) except Fault as e: log.err() raise except Exception as e: log.err() # This should not happen! Let the team know via email! if EXCEPTION_ADDRESS: email_exception(EXCEPTION_ADDRESS) raise InternalError(e)
def _wrap(*args, **kwargs): self = args[0] try: retval = f(*args, **kwargs) self.session.expunge_all() return retval except NoResultFound: raise ResourceNotFoundError(self.ctx.in_object) except Fault as e: log.err() raise except Exception as e: log.err() # This should not happen! Let the team know via email! email_exception(EXCEPTION_ADDRESS) raise InternalError(e)