Skip to content
campadrenalin edited this page Nov 23, 2012 · 4 revisions

The following is for reference. For an explanation of how DEJE works, go to the Technical Overview.

deje object

In your handler, you will have access to an object called "deje" in the global namespace. For Lua this is a table, for JavaScript it's an Object. The difference is essentially semantic. This object has properties and functions for interacting with your interpreter's host environment.

deje.get_resource(path)

Get the resource in this document that's available at the given path. Resources have the following properties:

  • path
  • type (MIME, basically)
  • content
  • comment

Content can be in any format, all other properties are plain strings.

deje.checkpoint(cp)

Create a checkpoint based on the arbitrary object cp.

deje.debug(text)

Print a debug message. At some point this will be disabled by default and only used for unit testing, but currently, such a switch does not exist.

deje.get_ident()

Get the host's current value of self-identity. May be None (or rather, it's equivalent in the handler's language)

deje.request_response(id, params)

Callback API

You can expose functions in the handler for events - in fact, that's the only useful way to do anything with a handler. Any functions by the following names, available in your interpreter's global namespace, will be called at the appropriate times by the host.

on_resource_update(path, property_name, oldpath)

This is triggered on changes to any property of a resource. In most of these cases, oldpath will be None, but if the path property has changed (property_name == path), the previous path is delivered in the oldpath variable. The following are valid results for property_name, see deje.handlers.lua.echo_chamber for more information.

  • path
  • type
  • content
  • comment
  • add
  • remove

on_checkpoint_achieve(cp)

checkpoint_test(cp)

quorum_participants()

quorum_thresholds()

on_host_request(id, params)


0.0.2

Clone this wiki locally