supercell.provider.
NoProviderFound
¶Raised if no matching provider for the client’s Accept header was found.
supercell.provider.
ProviderBase
¶Base class for content type providers.
Creating a new provider is just as simple as creating new consumers:
class MyProvider(s.ProviderBase):
CONTENT_TYPE = s.ContentType('application/xml')
def provide(self, model, handler):
self.set_header('Content-Type', 'application/xml')
handler.write(model.to_xml())
map_provider
(accept_header, handler, allow_default=False)¶Map a given content type to the correct provider implementation.
If no provider matches, raise a NoProviderFound exception.
Parameters: |
|
---|---|
Raises: |
provide
(model, handler)¶This method should return the correct representation as a simple string (i.e. byte buffer) that will be used as return value.
Parameters: | model (supercell.schematics.Model) – the model to convert to a certain content type |
---|