Web2py - Error when using SQLFORM.factory ()

0

I can not resolve an error that appears when I try to expose a form to two tables of 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, environment)         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.Alumn)         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 Framework documentation. If anyone knew how to help me, I would be very grateful.

    
asked by anonymous 24.07.2017 / 21:53

2 answers

0

This is a problem in the two most recent 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 will have a new version correcting this. In the meantime you can use the more stable earlier version, 2.14.6.

Web2py 2.14.6

    
26.07.2017 / 03:52
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 it recommends, I have to clone the repository and the current version is cloned ...

    
27.07.2017 / 05:12