User API Overview¶
Subpackages¶
Engel Application Classes¶
Contains all the classes and functions related to the structure of an Engel application.
-
class
engel.application.Application(debug=False)¶ Bases:
objectThe
Applicationabstract class represents the entirety of an Engel application.Your application should inherit from this class and redefine the specifics, like Views, Services, and any additional logic required by your project.
-
__init__(debug=False)¶ Constructor of the Application.
Parameters: debug – Sets the logging level of the application Raises: NotImplementedError – When Application.base_titlenot set in the class definition.
-
base_title= None¶ Page title pattern for the whole application. Gets set on a per-view basis by
Application.base_title.format(view.title).
-
dispatch(command)¶ Method used for sending events to the client. Refer to
engel/engeljs.jsto see the events supported by the client.Parameters: command – Command dict to send to the client.
-
register(event, callback, selector=None)¶ Resister an event that you want to monitor.
Parameters: - event – Name of the event to monitor
- callback – Callback function for when the event is received (Params: event, interface).
- selector – (Optional) CSS selector for the element(s) you want to monitor.
-
start(on_exit_callback=None)¶ Start the Engel application by initializing all registered services and starting an Autobahn IOLoop.
Parameters: on_exit_callback – Callback triggered on application exit
-
unregister(event, callback, selector=None)¶ Unregisters an event that was being monitored.
Parameters: - event – Name of the event to monitor
- callback – Callback function for when the event is received (Params: event, interface).
- selector – (Optional) CSS selector for the element(s) you want to monitor
-
-
class
engel.application.View(context)¶ Bases:
object-
__init__(context)¶ Constructor of the view.
Parameters: context – Application instantiating the view. Raises: NotImplementedError – When View.titleis not set.
-
build()¶ Method building the layout of the view. Override this in your view subclass to define your view’s layout.
-
dispatch(command)¶ Dispatch a command to the client at view-level.
Parameters: command – Command dict to send to the client.
-
libraries= []¶ List of modules encapsulating the javascript libraries used by the view.
-
on(event, callback, selector=None)¶ Wrapper around
register(). Ifon()is called, for instance, duringbuild(), the event handlers will be enqueued and registered when the view is loaded. Similarly, ifon()is called once the view is loaded (for example, in a button callback), the event handler will be registered immediately.Parameters: - event – Name of the event to monitor
- callback – Callback function for when the event is received (Params: event, interface).
- selector – (Optional) CSS selector for the element(s) you want to monitor
-
redirect(view_name)¶ Function used for view switching. Use it to get the callback in an event handler declaration.
self.on('click', self.redirect('myview'), '#' + mybtn.id)Parameters: view_name – Target view Returns: View loader callback
-
stylesheet= None¶ Stylesheet of the view.
-
title= None¶ Title of the view.
-
unload()¶ Overridable method called when a view is unloaded (either on view change or on application shutdown). Handles by default the unregistering of all event handlers previously registered by the view.
-