3. Modular page view

3.1. Page structure overview

3.2. Creating pages

Modular page views are created by subclassing the ModularPageView class:

class HomeView(ModularPageView):
 name = "HomeView"
 label = "Home View"
 injectVariables = ['ModelCommunicator', 'variables']
 modules = [AreaCalculator, UnitConverterModule, Company]

A modular page consists of modules, which can be activated by the user by clicking on the corresponding pill in the sidebar in the left of the page.

../_images/modular_page_view.png

A modular page example

3.3. Modules

Page modules may be one of the following types:

3.3.1. NumericalModel

../_images/modular_page_view.png

An active NumericalModel module

3.3.2. HtmlModule

class smo.web.modules.HtmlModule[source]

Page module consisting of blocks of HTML and JavaScript code

../_images/unit_converter_module.png

An active HtmlModule module

3.3.3. RestModule

class smo.web.modules.RestModule[source]

Page module generated from a restructured text document

../_images/company_module.png

An active RestModule module

3.4. Blocks

3.4.1. ModelView

smo.model.fields.ModelView

3.4.2. HtmlBlock

class smo.web.blocks.HtmlBlock(srcType=None, src=None)[source]

A block of HTML code

Parameters:
  • srcType (str) – ‘string’ or ‘file’
  • src (str) – the string of code or file path

3.4.3. JsBlock

class smo.web.blocks.JsBlock(srcType=None, src=None)[source]

A block of JavaScript code

Parameters:
  • srcType (str) – ‘string’ or ‘file’
  • src (str) – the string of code or file path