[IMP] introduce a new type of exception: WarningConfig. Note that no corresponding RPC_FAULT_CODE has been added; WarningConfig will share the same RPC_FAULT_CODE than Warning (RPC_FAULT_CODE_WARNING = 2)
Also remove a few whitespaces bzr revid: abo@openerp.com-20130118152346-5v4j94wjrq34hq4m
This commit is contained in:
parent
a075983249
commit
8bd622202b
|
@ -27,9 +27,17 @@ treated as a 'Server error'.
|
|||
|
||||
"""
|
||||
|
||||
import re
|
||||
|
||||
class Warning(Exception):
|
||||
pass
|
||||
|
||||
class WarningConfig(Exception):
|
||||
""" Warning bound to a misconfiguration. """
|
||||
def __init__(self, msg):
|
||||
# todo: treat the msg (regex)
|
||||
super(WarningConfig, self).__init__(msg)
|
||||
|
||||
class AccessDenied(Exception):
|
||||
""" Login/password error. No message, no traceback. """
|
||||
def __init__(self):
|
||||
|
|
|
@ -107,7 +107,7 @@ class ExportService(object):
|
|||
"""
|
||||
|
||||
_services = {}
|
||||
|
||||
|
||||
def __init__(self, name):
|
||||
ExportService._services[name] = self
|
||||
self.__name = name
|
||||
|
@ -306,6 +306,8 @@ def dispatch_rpc(service_name, method, params):
|
|||
raise
|
||||
except openerp.exceptions.Warning:
|
||||
raise
|
||||
except openerp.exceptions.WarningConfig:
|
||||
raise
|
||||
except openerp.exceptions.DeferredException, e:
|
||||
_logger.exception(tools.exception_to_unicode(e))
|
||||
post_mortem(e.traceback)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -145,7 +145,7 @@ class TinySocketClientThread(threading.Thread):
|
|||
break
|
||||
except Exception, e:
|
||||
try:
|
||||
valid_exception = Exception(netrpc_handle_exception_legacy(e))
|
||||
valid_exception = Exception(netrpc_handle_exception_legacy(e))
|
||||
valid_traceback = getattr(e, 'traceback', sys.exc_info())
|
||||
formatted_traceback = "".join(traceback.format_exception(*valid_traceback))
|
||||
_logger.debug("netrpc: communication-level exception", exc_info=True)
|
||||
|
@ -164,12 +164,14 @@ class TinySocketClientThread(threading.Thread):
|
|||
|
||||
def stop(self):
|
||||
self.running = False
|
||||
|
||||
|
||||
def netrpc_handle_exception_legacy(e):
|
||||
if isinstance(e, openerp.osv.osv.except_osv):
|
||||
return 'warning -- ' + e.name + '\n\n' + e.value
|
||||
if isinstance(e, openerp.exceptions.Warning):
|
||||
return 'warning -- Warning\n\n' + str(e)
|
||||
if isinstance(e, openerp.exceptions.WarningConfig):
|
||||
return 'warning -- Warning\n\n' + str(e)
|
||||
if isinstance(e, openerp.exceptions.AccessError):
|
||||
return 'warning -- AccessError\n\n' + str(e)
|
||||
if isinstance(e, openerp.exceptions.AccessDenied):
|
||||
|
|
|
@ -95,6 +95,8 @@ def xmlrpc_handle_exception(e):
|
|||
response = xmlrpclib.dumps(fault, allow_none=False, encoding=None)
|
||||
elif isinstance(e, openerp.exceptions.Warning):
|
||||
fault = xmlrpclib.Fault(RPC_FAULT_CODE_WARNING, str(e))
|
||||
elif isinstance(e, openerp.exceptions.WarningConfig):
|
||||
fault = xmlrpclib.Fault(RPC_FAULT_CODE_WARNING, str(e))
|
||||
response = xmlrpclib.dumps(fault, allow_none=False, encoding=None)
|
||||
elif isinstance (e, openerp.exceptions.AccessError):
|
||||
fault = xmlrpclib.Fault(RPC_FAULT_CODE_ACCESS_ERROR, str(e))
|
||||
|
@ -311,7 +313,7 @@ def http_to_wsgi(http_dir):
|
|||
handler.auth_provider.checkRequest(handler, path)
|
||||
except websrv_lib.AuthRequiredExc, ae:
|
||||
# Darwin 9.x.x webdav clients will report "HTTP/1.0" to us, while they support (and need) the
|
||||
# authorisation features of HTTP/1.1
|
||||
# authorisation features of HTTP/1.1
|
||||
if request_version != 'HTTP/1.1' and ('Darwin/9.' not in handler.headers.get('User-Agent', '')):
|
||||
start_response("403 Forbidden", [])
|
||||
return []
|
||||
|
|
Loading…
Reference in New Issue