All of our strategy classes include a content_type property, set to the content type for that strategy:
# web.responder.strategy.jsend
from web.responder.strategy.base import Base
class JsendStrategy(Base) :
content_type = 'application/json'
The most critical method is render(). If self.error is set, the JSend top-level key, status, is set to error. If self.data is set, on the other hand, the status key changes to success. The data stored in self.data is included in the final payload. The final return value is the product of the buildOutput() method from the base class:
def render(self) :
if self.error :
payload = { 'status' : 'error', 'message' : self.error }
if self.data :
count = 1
post = {}
for key, value in self.data.items() :
post.update({ key : value })
if count == 1 :
payload = { 'status' : &apos...