0

Ubuntu 18 - Python 3.6.9 - Mongo 4

使用 Web2py 给出的 SQLFORM 我在 PyDAL 中遇到错误:

AttributeError:“表”对象没有属性“_notnulls”

我正在使用我的 auth.user 表来制作表单,并且它正在与我的应用程序的其余部分一起使用,除非将它与 SQLFORM 一起使用并尝试处理()。

这是我抛出错误的代码,该代码是表单的标准 web2py 实践:

def my_form_processing(form):
        pass

db.auth_user.modified_by.writable = False
db.auth_user.created_by.writable = False
form = SQLFORM(db.auth_user)

if form.process(onvalidation=my_form_processing).accepted:
    session.flash = 'Record inserted'
    redirect(URL())
elif form.errors:
    response.flash = 'Form has errors'
else:
    session.flash = 'Please fill the form'

    return dict(form=form)

这是回溯:

Traceback (most recent call last):
  File "/opt/web2py/gluon/restricted.py", line 219, in restricted
    exec(ccode, environment)
  File "/opt/web2py/applications/connexxion/controllers/admin.py", line 380, in <module>
  File "/opt/web2py/gluon/globals.py", line 430, in <lambda>
    self._caller = lambda f: f()
  File "/opt/web2py/gluon/tools.py", line 3878, in f
    return action(*a, **b)
  File "/opt/web2py/applications/connexxion/controllers/admin.py", line 128, in adduser
    if form.process(onvalidation=my_form_processing).accepted:
  File "/opt/web2py/gluon/html.py", line 2339, in process
    self.validate(**kwargs)
  File "/opt/web2py/gluon/html.py", line 2277, in validate
    if self.accepts(**kwargs):
  File "/opt/web2py/gluon/sqlhtml.py", line 1994, in accepts
    self.vars.id = self.table.insert(**fields)
  File "/opt/web2py/gluon/packages/dal/pydal/objects.py", line 892, in insert
    ret = self._db._adapter.insert(self, row.op_values())
  File "/opt/web2py/gluon/packages/dal/pydal/adapters/mongo.py", line 475, in insert
    raise e
  File "/opt/web2py/gluon/packages/dal/pydal/adapters/mongo.py", line 471, in insert
    self.check_notnull(table, values)
  File "/opt/web2py/gluon/packages/dal/pydal/adapters/mongo.py", line 422, in check_notnull
    for fieldname in table._notnulls:
AttributeError: 'Table' object has no attribute '_notnulls'
4

0 回答 0