コード例 #1
0
ファイル: Rpc.py プロジェクト: gisce/openerp-client-kde
    def execute(self, obj, method, *args):
        """
        Same as call() but uses the notify mechanism to notify exceptions.

        Note that you'll need to bind gettext as texts sent to the notify
        module are localized.

        :param obj:
        :param method:
        :param args:
        :return:
        """
        count = 1
        while True:
            try:
                return self.call(obj, method, *args)
            except RpcProtocolException as err:
                if not Notifier.notifyLostConnection(count):
                    raise
            except RpcServerException as err:
                if err.type in ('warning', 'UserError'):
                    if err.info in ('ConcurrencyException') and len(args) > 4:
                        if Notifier.notifyConcurrencyError(args[0], args[2] and args[2][0], args[4]):
                            if ConcurrencyCheckField in args[4]:
                                del args[4][ConcurrencyCheckField]
                            return self.execute(obj, method, *args)
                    else:
                        Notifier.notifyWarning(err.info, err.data)
                else:
                    # Si venim a aquest punt l'error no es controlar i per tant
                    # s'ha de fer raise i tractar on toqui del Qgis.
                    raise
                return
            count += 1
コード例 #2
0
    def execute(self, obj, method, *args):
        """
        Same as call() but uses the notify mechanism to notify exceptions.

        Note that you'll need to bind gettext as texts sent to the notify
        module are localized.

        :param obj:
        :param method:
        :param args:
        :return:
        """
        count = 1
        while True:
            try:
                return self.call(obj, method, *args)
            except RpcProtocolException as err:
                if not Notifier.notifyLostConnection(count):
                    raise
            except RpcServerException as err:
                if err.type in ('warning', 'UserError'):
                    if err.info in ('ConcurrencyException') and len(args) > 4:
                        if Notifier.notifyConcurrencyError(args[0], args[2] and args[2][0], args[4]):
                            if ConcurrencyCheckField in args[4]:
                                del args[4][ConcurrencyCheckField]
                            return self.execute(obj, method, *args)
                    else:
                        Notifier.notifyWarning(err.info, err.data)
                else:
                    Notifier.notifyError(_('Application Error'), _(
                        'View details'), err.backtrace)
                raise
            count += 1
コード例 #3
0
 def execute(self, obj, method, *args):
     count = 1
     while True:
         try:
             return self.call(obj, method, *args)
         except RpcProtocolException, err:
             if not Notifier.notifyLostConnection(count):
                 raise
         except RpcServerException, err:
             if err.type in ('warning', 'UserError'):
                 if err.args[0] in (
                         'ConcurrencyException') and len(args) > 4:
                     if Notifier.notifyConcurrencyError(
                             args[0], args[2] and args[2][0], args[4]):
                         if ConcurrencyCheckField in args[4]:
                             del args[4][ConcurrencyCheckField]
                         return self.execute(obj, method, *args)
                 else:
                     Notifier.notifyWarning(err.args[0], err.args[1])
             else:
                 Notifier.notifyError(
                     _('Application Error: %s') % err.get_title(),
                     _('View details: %s') % err.get_details(),
                     err.backtrace)
             raise