Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么我在get_上传中的blobstore_handlers.py第348行出现错误?_Python_File_Google App Engine_Blobstore - Fatal编程技术网

Python 为什么我在get_上传中的blobstore_handlers.py第348行出现错误?

Python 为什么我在get_上传中的blobstore_handlers.py第348行出现错误?,python,file,google-app-engine,blobstore,Python,File,Google App Engine,Blobstore,我修补了appengine_配置以启用blobstoreuploadhandler的外来字符: webapp_django_version = '1.2' import base64 import quopri from webob import multidict def from_fieldstorage(cls, fs): obj = cls() if fs.list: # fs.list can be None when there's nothi

我修补了appengine_配置以启用blobstoreuploadhandler的外来字符:

webapp_django_version = '1.2'
import base64
import quopri

from webob import multidict


def from_fieldstorage(cls, fs):

    obj = cls()
    if fs.list:
        # fs.list can be None when there's nothing to parse
        for field in fs.list:
            if field.filename:
                obj.add(field.name, field)
            else:

                # first, set a common charset to utf-8.
                common_charset = 'utf-8'

                # second, check Content-Transfer-Encoding and decode
                # the value appropriately
                field_value = field.value
                transfer_encoding = field.headers.get(
                  'Content-Transfer-Encoding', None)

                if transfer_encoding == 'base64':
                    field_value = base64.b64decode(field_value)

                if transfer_encoding == 'quoted-printable':
                    field_value = quopri.decodestring(field_value)

                if field.type_options.has_key('charset') and \
                      field.type_options['charset'] != common_charset:
                    # decode with a charset specified in each
                    # multipart, and then encode it again with a
                    # charset specified in top level FieldStorage
                    field_value = field_value.decode(
                      field.type_options['charset']).encode(common_charset)

            # TODO: Should we take care of field.name here?
            obj.add(field.name, field_value)

    return obj

multidict.MultiDict.from_fieldstorage = classmethod(from_fieldstorage)
现在,当使用只有一个文件的表单执行上载时,会出现此错误。是因为我还需要文本值吗?如果我删除appengine_config的补丁,那么我的上传工作正常,但是外文字符中断。我是否应该尝试只添加一个隐藏变量,以便提交的每个文件都不仅仅是一个文件?谢谢你有什么好主意

Traceback (most recent call last):
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/_webapp25.py", line 703, in __call__
    handler.post(*groups)
  File "/base/data/home/apps/s~montaoproject/deleteoredit.354032237980992086/main.py", line 2659, in post
    for upload in self.get_uploads():
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/blobstore_handlers.py", line 348, in get_uploads
    for key, value in self.request.params.items():
  File "/base/python_runtime/python_lib/versions/1/webob/__init__.py", line 951, in params
    params = self.str_params
  File "/base/python_runtime/python_lib/versions/1/webob/__init__.py", line 943, in str_params
    return NestedMultiDict(self.str_GET, self.str_POST)
  File "/base/python_runtime/python_lib/versions/1/webob/__init__.py", line 870, in str_POST
    vars = MultiDict.from_fieldstorage(fs)
  File "/base/data/home/apps/s~montaoproject/deleteoredit.354032237980992086/appengine_config.py", line 44, in from_fieldstorage
    obj.add(field.name, field_value)
UnboundLocalError: local variable 'field_value' referenced before assignment
缩进“obj.add(field.name,field_value)”,使其成为else语句的一部分