Ledge Plugin Interface

Your plugin should inherit from one of the below classes, and override the following functionality.

Note

The Demo Handler and Demo Responder represent minimal implementations of the interfaces described below.

class ledge.HandlerImplementation(config)

Interface for classes that provide handlers.

name = 'UNSET_HANDLER_NAME'

The handler’s name. Used for logging and naming the subconfig. Override this in your plugin implementation. Leaving it set to the default will raise an error on init-ing your implementation.

subconfig = None

The subconfig object. This should be overridden in your subclass if you need to pass a subconfig up to the ledge configuration. It is expected to be a class that can be provided to environ.config()

handles(request, content)

Implement this in your subclass.

It should return a bool, True if this implementation should handle the request, otherwise False.

Parameters
Return type

bool

Returns

Whether or not this implementation should handle the provided request.

handle(request, content)

Implement this in your subclass.

Note that this method will be run its own thread, unless self.THREAD_SAFE is false-y.

Parameters
class ledge.ResponderImplementation(config)

Interface for classes that provide responders.

name = 'UNSET_RESPONDER_NAME'

The handler’s name. Used for logging. Override this in your plugin implementation. Leaving it set to the default will raise an error on init-ing your implementation.

subconfig = None

The subconfig object. This should be overridden in your subclass if you need to pass a subconfig up to the ledge configuration. It is expected to be a class that can be provided to environ.config()

handles(request, content)

Implement this in your subclass.

It should return a bool, True if this implementation should handle the request, otherwise False.

Parameters
Return type

bool

Returns

Whether or not this implementation should handle the provided request.

respond(request, content)

Implement this in your subclass.

Note that this method will be run in the reactor thread, so it should not block.

At some point the implementation _must_ call request.finish()

Parameters