Views I – Mastering Plone 5 development

Views I

Views I#

In this part you will:

  • Register a view that can be opened in the browser

  • Create and use a template for the view

Topics covered:

  • ZCML

A simple browser view#

Before writing the talk view itself we step back and have a brief look at views and templates.

A view in Plone is usually a BrowserView. It can hold a lot of cool Python code but we will first focus on the template.

Edit the file browser/configure.zcml and register a new view called training:

 1 <configure
 2   xmlns=""
 3   xmlns:browser=""
 4   xmlns:plone=""
 5   i18n_domain="">
 7   <!-- Set overrides folder for Just-a-Bunch-Of-Templates product -->
 8   <include package="z3c.jbot" file="meta.zcml" />
 9   <browser:jbot
10     directory="overrides"
11     layer=""
12     />
14   <!-- Publish static files -->
15   <browser:resourceDirectory
16     name=""
17     directory="static"
18     />
20   <browser:page
21     name="training"
22     for="*"
23     template="templates/"
24     permission="zope2.View"
25     />
27 </configure>

Add a file browser/templates/

<h1>Hello World</h1>

You now have everything in place to learn about page templates.


The view training has no Python class registered for it but only a template. It acts as if it had an empty Python class inheriting from Products.Five.browser.BrowserView but the way that happens is actually quite a bit of magic...