为什么我在上传图片时遇到异常错误:“Field”对象没有属性“__dir__”

问题描述 投票:0回答:1

我最近将我的 web2py 版本“升级”到最新版本(2.27.1),但我忘记了以前的版本。我在管理页面上进行了升级,方法是在 pythonanywhere.com 上托管的实时应用程序上单击标有“检查升级”的按钮。现在,当我尝试提交具有上传属性的表单时,突然出现以下错误:Field 对象没有属性“_ _ dir _ _”。不知何故,图像上传功能已被中断。在此之前web2py升级上传工作正常。有没有办法解决这个问题,下面是我从这个错误中得到的回溯和一些错误详细信息。如果我可以提交更多信息来帮助我的请求,请告诉我。

追溯

Field('logo', 'upload', label=SPAN('Your company logo'))

函数参数列表

Traceback (most recent call last): File "/home/myapp/web2py/gluon/restricted.py", line 219, in restricted exec(ccode, environment) File "/home/myapp/web2py/applications/init/controllers/default.py", line 920, in <module> File "/home/myapp/web2py/gluon/globals.py", line 463, in <lambda> self._caller = lambda f: f() File "/home/myapp/web2py/applications/init/controllers/default.py", line 315, in business_registration if form.process().accepted: File "/home/myapp/web2py/gluon/html.py", line 2410, in process self.validate(**kwargs) File "/home/myapp/web2py/gluon/html.py", line 2349, in validate if self.accepts(**kwargs): File "/home/myapp/web2py/gluon/sqlhtml.py", line 2132, in accepts source_file, original_filename, field.uploadfolder File "/home/myapp/web2py/gluon/packages/dal/pydal/objects.py", line 2075, in store self._tablename if '_tablename' in self.__dir__() and self._tablename else 'no_table', AttributeError: 'Field' object has no attribute '__dir__'

代码清单

filename='Kivy Documentation.pdf', path='/home/myapp/web2py/applications/init/static/business_docs')

在文件中:/home/myapp/web2py/applications/init/controllers/appadmin.py

m = re.search(REGEX_UPLOAD_EXTENSION, filename) extension = m and m.group(1) or "txt" uuid_key = self._db.uuid().replace("-", "")[-16:] if self._db else uuidstr() encoded_filename = to_native(base64.urlsafe_b64encode(to_bytes(filename))) newfilename = "%s.%s.%s.%s" % ( self._tablename if '_tablename' in self.__dir__() and self._tablename else 'no_table', self.name, uuid_key, encoded_filename, )

我认为你必须使用
"/home/myapp/web2py/applications/init/controllers/appadmin.py", line 7>
python web2py
1个回答
0
投票
__dir__

。所以这个

__dir__()
应更改为以下一项:

self._tablename if '_tablename' in self.__dir__() and self._tablename else 'no_table',

© www.soinside.com 2019 - 2024. All rights reserved.