コード例 #1
0
 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))
コード例 #2
0
 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))
コード例 #3
0
    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
コード例 #4
0
ファイル: Request.py プロジェクト: yay-couch/couch-py
   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