Finally, the HalJsonStrategy class is configured in a similar manner:
# web.responder.strategy.hal_json
from web.responder.strategy.base import Base
class HalJsonStrategy(Base) :
content_type = 'application/hal+json'
You might notice that the render() method for this format is even more concise as data values are directly placed at the top level:
def render(self) :
payload = dict({'_links':{'self':{'href':self.link }}})
if self.error :
payload['error'] = self.error
if self.data :
for key, value in self.data.items() :
payload.update({ key : value })
return self.buildOutput(self.content_type, payload)
Let's now create a REST responder.