HelloCMS!

Let's make this even more interesting, and create our own simple CMS. For this, we can have the route expect a template name (a page) in the URL and then just render it. We could then dynamically create web pages and have them served by our CMS.

It turns out that this is quite easy to do:

@http.route('/hellocms/<page>', auth='public') 
def hello(self, page, **kwargs): 
    return http.request.render(page) 

The page argument should match a Template External ID. If you open http://localhost:8069/hellocms/todo_website.hello in your web browser, you should see our Hello World web page!

In fact, the built-in website module provides CMS features, including a more robust implementation of this, at the /page endpoint route.

In werkzeug jargon, ...

Get Odoo 11 Development Essentials - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.