wotpy.protocols.http.handlers.event

Request handler for Event interactions.

Classes

EventObserverHandler(application, request, …) Handler for Event subscription requests.
class wotpy.protocols.http.handlers.event.EventObserverHandler(application, request, **kwargs)

Bases: tornado.web.RequestHandler

Handler for Event subscription requests.

get(thing_name, name)

Subscribes to the given Event and waits for the next emission (HTTP long-polling pattern). Returns the event emission payload and destroys the subscription afterwards.

initialize(http_server)

Hook for subclass initialization. Called for each request.

A dictionary passed as the third argument of a url spec will be supplied as keyword arguments to initialize().

Example:

class ProfileHandler(RequestHandler):
    def initialize(self, database):
        self.database = database

    def get(self, username):
        ...

app = Application([
    (r'/user/(.*)', ProfileHandler, dict(database=database)),
    ])
on_finish()

Destroys the subscription to the observable when the request finishes.