def toJson(self, encode = True): """ Get attachment data as json string that CouchDB expects. @param (bool) encode @return (str) """ return util.jsonEncode(self.toArray(encode))
def toJson(self, encode=True): """ Get attachment data as json string that CouchDB expects. @param (bool) encode @return (str) """ return util.jsonEncode(self.toArray(encode))
def setBody(self, body=None): """ Set body. @param (mixed) body @return (self) """ if (body != None and self.method != Request.METHOD_HEAD and self.method != Request.METHOD_GET): # decode if provided if self.getHeader("Content-Type") == "application/json": body = util.jsonEncode(body) self.body = body self.headers["Content-Length"] = len(body) return self
def setBody(self, body = None): """ Set body. @param (mixed) body @return (self) """ if (body != None and self.method != Request.METHOD_HEAD and self.method != Request.METHOD_GET): # decode if provided if self.getHeader("Content-Type") == "application/json": body = util.jsonEncode(body) self.body = body self.headers["Content-Length"] = len(body) return self