**Note**: More to come...
The EMEN2 web interface can be extended fairly easily.
First, create a directory with the following structure:
<ext>/ /__init__.py /views/ /views/__init__.py /views/example.py /templates/ /templates/example/ /templates/example/example.mako
In example.py:
from emen2.web.view import View @View.register class ExampleView(View): @View.add_matcher(r'^/example/square/(?P<value>[^/]*)/$') def example_test(self, value): self.title = 'Example extension' self.template = '/example/example' value = int(value) self.ctxt['value'] = value self.ctxt['value_square'] = value ** 2
In example.mako:
<%inherit file="/page" /> <h1>Example</h1> <p>This is an example of how to create a view and template.</p> <p>The value argument was: ${value}</p> <p>The value argument squared is ${value_square}, or ${value**2}</p>
And finally, in <ext>/views/init.py:
import example