Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
5134 Lượt xem

I'm trying to hide the debug code from seesion expired error, so i need to override the _handle_exception method to delete debug code from exception. Can anyone explain how to do this ?

Ảnh đại diện
Huỷ bỏ
Tác giả

I need to override def in http.py class JSONRequest method _handle_exception

Câu trả lời hay nhất

Hi Kitty,

You can do it like this.

Inside the controller,

from odoo.addons.base.ir import ir_http

class IrHttp(ir_http.IrHttp):

@classmethod
def _handle_exception(cls, exception):
# If handle_exception returns something different than None, it will be used as a response

# This is done first as the attachment path may
# not match any HTTP controller
if isinstance(exception, werkzeug.exceptions.HTTPException) and exception.code == 404:
attach = cls._serve_attachment()
if attach:
return attach

# Don't handle exception but use werkeug debugger if server in --dev mode
if 'werkzeug' in tools.config['dev_mode']:
raise
try:
return request._handle_exception(exception)
except AccessDenied:
return werkzeug.exceptions.Forbidden()

Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 5 25
885
0
thg 2 22
2921
2
thg 1 22
3024
2
thg 1 22
4160
0
thg 9 21
200