odoo8 框架,路由加载失败问题

openerp(odoo8) 框架,路由加载失败问题

openerp框架,路由问题:
若未将路由所在的模块强制加载到root类中,并且未在访问路由的时候传headers信息:Cookie:{session_id: ‘xxx’},就会导致状态码为404的错误。
解决办法:
修改openerp框架下的http.py中的root类,把路由所在的模块强制加载进来。
self.nodb_routing_map = routing_map([’’, “web”,“xxx”,], True)

class Root(object):
    """Root WSGI application for the OpenERP Web Client.
    """
    def __init__(self):
        # Setup http sessions
        path = session_path()
        _logger.debug('HTTP sessions stored in: %s', path)
        self.session_store = werkzeug.contrib.sessions.FilesystemSessionStore(path, session_class=OpenERPSession)

        # TODO should we move this to ir.http so that only configured modules are served ?
        _logger.info("HTTP Configuring static files")
        self.load_addons()

        _logger.info("Generating nondb routing")
        # **************************************将路由所在模块添加到此处
        self.nodb_routing_map = routing_map(['', "web","xxx",], True)	
        # **************************************
    def __call__(self, environ, start_response):
        """ Handle a WSGI request
        """
        return self.dispatch(environ, start_response)

    def load_addons(self):
        """ Load all addons from addons patch containg static files and
        controllers and configure them.  """
        statics = {}

        for addons_path in openerp.modules.module.ad_paths:
            for module in sorted(os.listdir(str(addons_path))):
                if module not in addons_module:
                    manifest_path = os.path.join(addons_path, module, '__openerp__.py')
                    path_static = os.path.join(addons_path, module, 'static')
                    if os.path.isfile(manifest_path) and os.path.isdir(path_static):
                        manifest = ast.literal_eval(open(manifest_path).read())
                        manifest['addons_path'] = addons_path
                        _logger.debug("Loading %s", module)
                        if 'openerp.addons' in sys.modules:
                            m = __import__('openerp.addons.' + module)
                        addons_module[module] = m
                        addons_manifest[module] = manifest
                        statics['/%s/static' % module] = path_static

        app = werkzeug.wsgi.SharedDataMiddleware(self.dispatch, statics)
        self.dispatch = DisableCacheMiddleware(app)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值