In web module (addons/web) exist all of the routes (many of them) in Openerp, for example:
etc. But I want to extend the web module to create other ways (routes) of clients registration. I created a module web_aaa (for testing) and in a controller I include this (almost all the code copied from web/controllers/main.py class Home):
# -*- coding: utf-8 -*-
import logging
import jinja2
import simplejson
import os
import sys
import openerp
from openerp import http
from openerp.http import request, serialize_exception as _serialize_exception
_logger = logging.getLogger(__name__)
if hasattr(sys, 'frozen'):
path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'views'))
loader = jinja2.FileSystemLoader(path)
else:
loader = jinja2.PackageLoader('openerp.addons.web', "views")
env = jinja2.Environment(loader=loader, autoescape=True)
env.filters["json"] = simplejson.dumps
class Home_aaa(http.Controller):
#This is a new route
@http.route('/signup', type='http', auth="none")
def signup(self, **kw):
return env.get_template("signup.html").render()
Then, when I start the server with "--load web_aaa" and lookup for /signup it works fine. But all the others routes of web module return 404 Not Found (None werkzeug: 192.168.56.1 - - [10/Nov/2014 19:00:44] "GET /web/ HTTP/1.1" 404 -).
And when I start the server without "--load web_aaa" all the routes of web module works great, but web_aaa routes not.
My questions are:
Thanks very much!!
Your cant test:
from web.controllers.main import Home
class Home_aaa(Home):
http.route('/signup', type='http', auth="none")
def signup(self, **kw):
return env.get_template("signup.html").render()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.