Provider

A Provider is the equivalent to a Consumer only that it transforms the request handler’s resulting model into a serialization requested from the client. The client is then able to request a certain serialization using the Accept header in her request.

Defining providers for a request handler is done using the provides decorator on the class definition:

@s.provides(s.MediaType.ApplicationJson)
class MyHandler(s.RequestHandler):
    pass

Create custom provider

A provider can be created equivalently to a consumer:

class JsonProvider(ConsumerBase):

    CONTENT_TYPE = ContentType(MediaType.ApplicationJson)

    def provide(self, model, handler):
        handler.write(model.validate())

For Producers the same remarks about the content type hold as for the Consumers.

Read the Docs v: latest
Versions
latest
v0.4.0
v0.3.0
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.