當前位置: 首頁>>代碼示例>>Python>>正文


Python wsgi.input方法代碼示例

本文整理匯總了Python中twisted.web.wsgi.input方法的典型用法代碼示例。如果您正苦於以下問題:Python wsgi.input方法的具體用法?Python wsgi.input怎麽用?Python wsgi.input使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在twisted.web.wsgi的用法示例。


在下文中一共展示了wsgi.input方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __setitem__

# 需要導入模塊: from twisted.web import wsgi [as 別名]
# 或者: from twisted.web.wsgi import input [as 別名]
def __setitem__(self, key, value):
        """ Change an environ value and clear all caches that depend on it. """

        if self.environ.get('bottle.request.readonly'):
            raise KeyError('The environ dictionary is read-only.')

        self.environ[key] = value
        todelete = ()

        if key == 'wsgi.input':
            todelete = ('body', 'forms', 'files', 'params', 'post', 'json')
        elif key == 'QUERY_STRING':
            todelete = ('query', 'params')
        elif key.startswith('HTTP_'):
            todelete = ('headers', 'cookies')

        for key in todelete:
            self.environ.pop('bottle.request.'+key, None) 
開發者ID:Autodesk,項目名稱:arnold-usd,代碼行數:20,代碼來源:__init__.py

示例2: _body

# 需要導入模塊: from twisted.web import wsgi [as 別名]
# 或者: from twisted.web.wsgi import input [as 別名]
def _body(self):
        try:
            read_func = self.environ['wsgi.input'].read
        except KeyError:
            self.environ['wsgi.input'] = BytesIO()
            return self.environ['wsgi.input']
        body_iter = self._iter_chunked if self.chunked else self._iter_body
        body, body_size, is_temp_file = BytesIO(), 0, False
        for part in body_iter(read_func, self.MEMFILE_MAX):
            body.write(part)
            body_size += len(part)
            if not is_temp_file and body_size > self.MEMFILE_MAX:
                body, tmp = TemporaryFile(mode='w+b'), body
                body.write(tmp.getvalue())
                del tmp
                is_temp_file = True
        self.environ['wsgi.input'] = body
        body.seek(0)
        return body 
開發者ID:brycesub,項目名稱:silvia-pi,代碼行數:21,代碼來源:bottle.py

示例3: __setitem__

# 需要導入模塊: from twisted.web import wsgi [as 別名]
# 或者: from twisted.web.wsgi import input [as 別名]
def __setitem__(self, key, value):
        """ Change an environ value and clear all caches that depend on it. """

        if self.environ.get('bottle.request.readonly'):
            raise KeyError('The environ dictionary is read-only.')

        self.environ[key] = value
        todelete = ()

        if key == 'wsgi.input':
            todelete = ('body', 'forms', 'files', 'params', 'post', 'json')
        elif key == 'QUERY_STRING':
            todelete = ('query', 'params')
        elif key.startswith('HTTP_'):
            todelete = ('headers', 'cookies')

        for key in todelete:
            self.environ.pop('bottle.request.' + key, None) 
開發者ID:brycesub,項目名稱:silvia-pi,代碼行數:20,代碼來源:bottle.py

示例4: body

# 需要導入模塊: from twisted.web import wsgi [as 別名]
# 或者: from twisted.web.wsgi import input [as 別名]
def body(self):
        """ The HTTP request body as a seekable buffer object.

            This property returns a copy of the `wsgi.input` stream and should
            be used instead of `environ['wsgi.input']`.
         """
        if self._body is None:
            maxread = max(0, self.content_length)
            stream = self.environ['wsgi.input']
            self._body = BytesIO() if maxread < MEMFILE_MAX else TemporaryFile(mode='w+b')
            while maxread > 0:
                part = stream.read(min(maxread, MEMFILE_MAX))
                if not part: #TODO: Wrong content_length. Error? Do nothing?
                    break
                self._body.write(part)
                maxread -= len(part)
            self.environ['wsgi.input'] = self._body
        self._body.seek(0)
        return self._body 
開發者ID:lrq3000,項目名稱:pyFileFixity,代碼行數:21,代碼來源:bottle2.py

示例5: body

# 需要導入模塊: from twisted.web import wsgi [as 別名]
# 或者: from twisted.web.wsgi import input [as 別名]
def body(self):
        """ The HTTP request body as a seekable buffer object.
        
            This property returns a copy of the `wsgi.input` stream and should
            be used instead of `environ['wsgi.input']`.
         """
        if self._body is None:
            maxread = max(0, self.content_length)
            stream = self.environ['wsgi.input']
            self._body = BytesIO() if maxread < MEMFILE_MAX else TemporaryFile(mode='w+b')
            while maxread > 0:
                part = stream.read(min(maxread, MEMFILE_MAX))
                if not part: #TODO: Wrong content_length. Error? Do nothing?
                    break
                self._body.write(part)
                maxread -= len(part)
            self.environ['wsgi.input'] = self._body
        self._body.seek(0)
        return self._body 
開發者ID:lrq3000,項目名稱:pyFileFixity,代碼行數:21,代碼來源:bottle3.py

示例6: _body

# 需要導入模塊: from twisted.web import wsgi [as 別名]
# 或者: from twisted.web.wsgi import input [as 別名]
def _body(self):
        """ The HTTP request body as a seekable file-like object.

            This property returns a copy of the `wsgi.input` stream and should
            be used instead of `environ['wsgi.input']`.
         """
        maxread = max(0, self.content_length)
        stream = self.environ['wsgi.input']
        body = BytesIO() if maxread < MEMFILE_MAX else TemporaryFile(mode='w+b')
        while maxread > 0:
            part = stream.read(min(maxread, MEMFILE_MAX))
            if not part: break
            body.write(part)
            maxread -= len(part)
        self.environ['wsgi.input'] = body
        body.seek(0)
        return body 
開發者ID:gabrielStanovsky,項目名稱:props,代碼行數:19,代碼來源:bottle.py

示例7: _body

# 需要導入模塊: from twisted.web import wsgi [as 別名]
# 或者: from twisted.web.wsgi import input [as 別名]
def _body(self):
        body_iter = self._iter_chunked if self.chunked else self._iter_body
        read_func = self.environ['wsgi.input'].read
        body, body_size, is_temp_file = BytesIO(), 0, False
        for part in body_iter(read_func, self.MEMFILE_MAX):
            body.write(part)
            body_size += len(part)
            if not is_temp_file and body_size > self.MEMFILE_MAX:
                body, tmp = TemporaryFile(mode='w+b'), body
                body.write(tmp.getvalue())
                del tmp
                is_temp_file = True
        self.environ['wsgi.input'] = body
        body.seek(0)
        return body 
開發者ID:Autodesk,項目名稱:arnold-usd,代碼行數:17,代碼來源:__init__.py


注:本文中的twisted.web.wsgi.input方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。