wotpy.protocols.http.handlers.property

Request handler for Property interactions.

Classes

PropertyObserverHandler(application, …) Handler for Property subscription requests.
PropertyReadWriteHandler(application, …) Handler for Property get/set requests.
class wotpy.protocols.http.handlers.property.PropertyObserverHandler(application, request, **kwargs)

Bases: tornado.web.RequestHandler

Handler for Property subscription requests.

get(thing_name, name)

Subscribes to Property updates and waits for the next event (HTTP long-polling pattern). Returns the updated value and destroys the subscription.

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.

class wotpy.protocols.http.handlers.property.PropertyReadWriteHandler(application, request, **kwargs)

Bases: tornado.web.RequestHandler

Handler for Property get/set requests.

get(thing_name, name)

Reads and returns the Property value.

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)),
    ])
put(thing_name, name)

Updates the Property value.