Web2py - Error using SQLFORM.Factory()

Asked

Viewed 149 times

0

I can’t fix one error that appears when I try to expose a form to two tables of the SQLite.

The error is as follows:

Traceback (Most recent call last): File "/home/Joao/Desktop/web2py/gluon/Restricted.py", line 219, in Restricted exec(ccode, Nvironment) File "/home/Joao/Desktop/web2py/Applications/Vr/controllers/default.py", line 101, in File "/home/Joao/Desktop/web2py/gluon/globals.py", line 409, in self. _Caller = lambda f: f() File "/home/Joao/Desktop/web2py/Applications/Vr/controllers/default.py", line 55, in register_student form = SQLFORM.Factory(db.Person,db.Student) File "/home/Joao/Desktop/web2py/gluon/sqlhtml.py", line 1922, in Factory Return SQLFORM(DAL(None). define_table(table_name, *[field.clone() for field in Fields]), Attributeerror: 'Table' Object has no attribute 'clone'

My controller and my model are as follows::

Model:

    db.define_table('Pessoa',
    Field('nome',required=True,notnull=True),
    Field('cpf',required=False,notnull=True,length=11),
    Field('data_de_nascimento',type='date',required=False,notnull=True),
    Field('cep',notnull=True,length=8),
    Field('uf',notnull=True,length=2),
    Field('pai',notnull=True),
    Field('mae',notnull=True),
    Field('identidade',notnull=True,length=13),
    Field('expedicao_identidade',type='date',required=False,notnull=True),
    Field('tipo_sanguineo',notnull=True,length=3),
    Field('orgao_emissor',notnull=True,length=20),
    Field('doador',type='boolean', notnull=True),
    Field('origem',notnull=True,length=40),
    Field('observacao',notnull=True),
    auth.signature,
)

db.define_table('Aluno',
    Field('pessoa_id', 'reference Pessoa', writable=False, readable=False),
    # Field('nota_fiscal_id', 'reference Nota_fiscal', writable=False, readable=False),
    Field('matricula', notnull=True, length=7),
    Field('renach', notnull=True, length=40),
    Field('categoria', notnull=True, length=5),
    Field('servico', notnull=True),
    Field('status', notnull=True),
    auth.signature,
)

Controller:

def register_student():
    form = SQLFORM.factory(db.Pessoa,db.Aluno)

    if form.process().accepted:

        id = db.Pessoa.insert(**db.Pessoa._filter_fields(form.vars))
        form.vars.client=id
        id = db.Aluno.insert(**db.Aluno._filter_fields(form.vars))
        response.flash='Aluno cadastrado com sucesso!'

    return dict(form=form)

I did all this based on the official documentation of Framework. If anyone can help me I’d be very grateful.

2 answers

0


It is a problem present in the two latest versions: 2.15.1 and 2.15.2. The second one left to correct the first one after a few days. In a few days we’ll have a new version fixing that. Meanwhile you can use the previous version more stable, 2.14.6.

Web2py 2.14.6

0

When I try to open web2py it happens Carlos:

python web2py.py -a 123
Traceback (most recent call last):
  File "web2py.py", line 21, in <module>
    import gluon.widget
  File "/home/joao/Desktop/web2py-R-2.14.6/gluon/__init__.py", line 29, in <module>
    "You can also download a complete copy from http://www.web2py.com."
RuntimeError: web2py depends on pydal, which apparently you have not installed.
Probably you cloned the repository using git without '--recursive'
To fix this, please run (from inside your web2py folder):

     git submodule update --init --recursive

You can also download a complete copy from http://www.web2py.com.

And when I try to do what he recommends, I have to clone the repository and the current version is cloned...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.