Base Gizmo API

Server, python

Gizmo.gizmoid
A string identfier for this gizmo.
Used as registration key for this gizmo,
and passed on to client as JavaScript object name.

Gizmo.elem_names
[str], of names to be exposed on the client.

Gizmo.dhi
The dhi instance on which this gizmo instance
is attached to, and may contribute to.
Typically, this is the dhi of the current hit.

Gizmo.styles
{ name: { property: value } }, dictionary by exposed name,
of dictionaries of CSS property values.

Gizmo.js_gizmo_name
If None, __class__.__name__ is assumed as javascript type.

Gizmo.js_files
Gizmo.css_files

[str], of JavaScript and CSS files, respectively.

Gizmo.js_init
Template for JavaScript code to initialize this gizmo.

Gizmo.register(gizmoid)
Register this gizmo, using gizmoid as key.

Gizmo.get_id(name)
Get the unique page id for this name.

Gizmo.get(name, default=None)
Get value for name, from
the template evaluation namespace.

Gizmo.eval
An Evaluator instance for evaluating gizmo
boilerplate markup. Any kwargs passed
to a renderer method resets the locals
of this Evaluator instance.

Gizmo.init_styles()
Gizmo.set_style(css_class, prop, val)
Gizmo.add_css_codes(*css_codes)
Gizmo.add_js_codes(*js_codes)
Gizmo.add_onload_actions(*onload_actions)

Methods that modify gizmo internal data attributes only.

Gizmo.prepare_dhi(**kw)

Updates the hit’s dhi instance from
internal data. Any keywords are passed on
to the various code template renderers.

Gizmo.render_onload_actions(**kw)
Gizmo.render_styles(**kw)
Gizmo.render_css(**kw)
Gizmo.render_js(**kw)

Rendering support methods.

Gizmo.render(**kw)
Subclasses must provide an implementation.

Client, javascript

Gizmo.gizmoid
String, page unique identifier.
Doing an eval(gizmoid)
will give the gizmo javascript object.

Gizmo.elem_names
[String], of exposed names. Set automatically.

Gizmo.event_handlers
{ event: func | null }, of supported events and handlers.

Gizmo.onload()
Always called on page onload, unless overriden.

Gizmo.get_elem_names()
Get list of exposed element names.

Gizmo.is_exposed(name)
Is element name exposed?

Gizmo.get_id(name)
Get the unique page id for this name.

Gizmo.get_elem(name)
Get the element for name.

Gizmo.set_event_handler(event, func)
Set func as handler for the supported event event.

Gizmo.handle_event(event)
Call the handler, if any, for the supported event event.