supercell.consumer.
NoConsumerFound
¶Raised if no matching consumer for the client’s Content-Type header was found.
supercell.consumer.
ConsumerBase
¶Base class for content type consumers.
In order to create a new consumer, you must create a new class that
inherits from ConsumerBase
and sets the
ConsumerBase.CONTENT_TYPE
variable:
class MyConsumer(s.ConsumerBase):
CONTENT_TYPE = s.ContentType('application/xml')
def consume(self, handler, model):
return model(lxml.from_string(handler.request.body))
See also
supercell.api.consumer.JsonConsumer.consume
consume
(handler, model)¶This method should return the correct representation as a parsed model.
Parameters: | model (schematics.models.Model ) – the model to convert to a certain content type |
---|
map_consumer
(content_type, handler)¶Map a given content type to the correct provider implementation.
If no provider matches, raise a NoProviderFound exception.
Parameters: |
|
---|---|
Raises: |